Lweb and String 超级大水题
Lweb and String
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 261 Accepted Submission(s): 174
Oneday, he decided to transform this string to a new sequence.
You need help him determine this transformation to get a sequence which has the longest LIS(Strictly Increasing).
You need transform every letter in this string to a new number.
A is the set of letters of S, B is the set of natural numbers.
Every injection f:A→B can be treat as an legal transformation.
For example, a String “aabc”, A={a,b,c}, and you can transform it to “1 1 2 3”, and the LIS of the new sequence is 3.
Now help Lweb, find the longest LIS which you can obtain from S.
LIS: Longest Increasing Subsequence. (https://en.wikipedia.org/wiki/Longest_increasing_subsequence)
Then T lines follow, the i-th line contains a string S only containing the lowercase letters, the length of S will not exceed 105.
aabcc
acdeaa
Case #2: 4
#include<stdio.h>
#include<string.h>
#define N 10000006
char s[N];
int a[N];
int main(void)
{
int t, ans, i, j;
scanf("%d", &t);
j = 0;
while(t--)
{
j++;
ans = 0;
memset(a, 0, sizeof(a));
scanf("%s", s);
int n = strlen(s);
for(i = 0; i < n; i++)
a[s[i] - 'a' + 1]++;
for(i = 1; i <= 26; i++)
{
if(a[i])//判断26个英文字母是否出现过, 出现过长度就加1.
ans++;
}
printf("Case #%d: %d\n", j, ans);
}
}
Lweb and String 超级大水题的更多相关文章
- HDU 5842 Lweb and String (水题)
Lweb and String 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5842 Description Lweb has a string S ...
- hdu 1228 A+B 字符串处理 超级大水题
中文意思不解释. 很水,我本来想用switch处理字符串,然后编译不通过...原来switch只能处理整数型的啊,我都忘了. 然后就有了很挫的一大串if代码了... 代码: #include < ...
- hdu 4548 美素数 超级大水题
美素数 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) Total Submis ...
- hdu 1229 超级大水题
Time Limit: 1000MS Memory Limit: 32768KB 64bit IO Format: %I64d & %I64u Submit Status Desc ...
- HDU 5842 Lweb and String 水题
Lweb and String 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5842 Description Lweb has a string S ...
- PAT甲题题解-1101. Quick Sort (25)-大水题
快速排序有一个特点,就是在排序过程中,我们会从序列找一个pivot,它前面的都小于它,它后面的都大于它.题目给你n个数的序列,让你找出适合这个序列的pivot有多少个并且输出来. 大水题,正循环和倒着 ...
- PAT甲题题解-1117. Eddington Number(25)-(大么个大水题~)
如题,大水题...贴个代码完事,就这么任性~~ #include <iostream> #include <cstdio> #include <algorithm> ...
- [BFS,大水题] Codeforces 198B Jumping on Walls
题目:http://codeforces.com/problemset/problem/198/B Jumping on Walls time limit per test 2 seconds mem ...
- HDU 5842 Lweb and String(Lweb与字符串)
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...
随机推荐
- 《C# 爬虫 破境之道》:第二境 爬虫应用 — 第二节:以事件驱动状态、数据处理
续上一节内容,对Web爬虫进行进一步封装,通过委托将爬虫自己的状态变化以及数据变化暴露给上层业务处理或应用程序. 为了方便以后的扩展,我先定义一个蚂蚁抽象类(Ant),并让WorkerAnt(工蚁)继 ...
- Gitlab应用——系统管理
查看linux系统信息 查看日志 创建账号 选择regular,这是一个普通账号,点击“create user”账号创建完成 点击“User”,然后点击“New user”.使 ...
- restframework 序列化补充(自定义ModelSerializerl)
一.知识点 1.source title = serializers.CharField(source='courses.title') source用于one2one.foreginkey.choi ...
- 浏览器警告Failed to decode downloaded font和OTS parsing error: Failed to convert *** font to ***
昨晚,在做一个自己感兴趣的东西时,发现浏览器报警告,Failed to decode downloaded font以及OTS parsing error: Failed to convert *** ...
- 实用代码|javaMail发送邮件(文末重磅资源!)
每天进步一点点,距离大腿又近一步!阅读本文大概需要5分钟 JavaMail发送邮件,简单实用,了解一下呗~ 1.开启邮箱MAP/SMTP服务,获取第三方授权码 以QQ邮箱为例 2.主要代码 maven ...
- 痞子衡嵌入式:语音处理工具pzh-speech诞生记(4)- 音频录播实现(PyAudio)
大家好,我是痞子衡,是正经搞技术的痞子.今天痞子衡给大家介绍的是语音处理工具pzh-py-speech诞生之音频录播实现. 音频录播是pzh-py-speech的主要功能,pzh-py-speech借 ...
- 51Nod 1238 - 最小公倍数之和 V3(毒瘤数学+杜教筛)
题目 戳这里 推导 ∑i=1n∑j=1nlcm(i,j)~~~\sum_{i=1}^{n}\sum_{j=1}^{n}lcm(i,j) ∑i=1n∑j=1nlcm(i,j) =∑i=1n∑j= ...
- 团队项目-Beta冲刺1(七个小矮人)
团队项目-Beta冲刺1(七个小矮人) 一.格式描述 这个作业属于哪个课程 https://edu.cnblogs.com/campus/xnsy/GeographicInformationScien ...
- ugui制作伸缩菜单
制作一个类似与这种格式的菜单,可以伸缩滑动的.今天正好项目需要用到类似功能,所以尝试了一下,做出如下的效果 虽然只是一个思路,但是可以扩展.声明一个object物体,为but,通过GetCompone ...
- (ES6)JavaScript中面向对象类的实现
在ES5中,我们就知道JS是不支持面向对象的,所以用函数模拟了一个构造函数来实现类的.那么在ES6中,在ES5的原理基础上,将代码书写更为简单,明了. 一.怎样用ES6创建类?首先看一看例子: cla ...