Lweb and String

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 368    Accepted Submission(s): 243

Problem Description
Lweb has a string S.

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)

 
Input
The first line of the input contains the only integer T,(1≤T≤20).

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.

 
Output
For each test case, output a single line "Case #x: y", where x is the case number, starting from 1. And y is the answer.
 
Sample Input
2
aabcc
acdeaa
 
Sample Output
Case #1: 3
Case #2: 4
 
Author
UESTC
 
Source

解析:说了那么多,其实很简单,就是求有多少种字母。

#include <cstdio>
#include <cstring> const int MAXN = 1e5+5;
char s[MAXN];
bool vis[30]; int main()
{
int t, cn = 0;
scanf("%d", &t);
while(t--){
scanf("%s", s);
memset(vis, 0, sizeof(vis));
int res = 0;
for(int i = 0; s[i] != '\0'; ++i){
if(!vis[s[i]-'a']){
vis[s[i]-'a'] = true;
++res;
}
}
printf("Case #%d: %d\n", ++cn, res);
}
return 0;
}

  

HDU 5842 Lweb and String的更多相关文章

  1. HDU 5842 Lweb and String(Lweb与字符串)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  2. HDU 5842 Lweb and String (水题)

    Lweb and String 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5842 Description Lweb has a string S ...

  3. HDU 5842 Lweb and String 水题

    Lweb and String 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5842 Description Lweb has a string S ...

  4. Lweb and String 超级大水题

    Lweb and String Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)T ...

  5. hdu 4850 Wow! Such String! 欧拉回路

    作者:jostree 转载请注明出处 http://www.cnblogs.com/jostree/p/4080264.html 题目链接:hdu 4850 Wow! Such String! 欧拉回 ...

  6. hdu 3553 Just a String (后缀数组)

    hdu 3553 Just a String (后缀数组) 题意:很简单,问一个字符串的第k大的子串是谁. 解题思路:后缀数组.先预处理一遍,把能算的都算出来.将后缀按sa排序,假如我们知道答案在那个 ...

  7. HDU 4850 Wow! Such String!(欧拉道路)

    HDU 4850 Wow! Such String! 题目链接 题意:求50W内的字符串.要求长度大于等于4的子串,仅仅出现一次 思路:须要推理.考虑4个字母的字符串,一共同拥有26^4种,这些由这些 ...

  8. 2016中国大学生程序设计竞赛 - 网络选拔赛 1011 Lweb and String

    Problem Description Lweb has a string S. Oneday, he decided to transform this string to a new sequen ...

  9. HDU 3336 Count the string(KMP的Next数组应用+DP)

    Count the string Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

随机推荐

  1. SDUT1500 Message Flood

    以前做过的用的字典树,可是貌似现在再用超内存....求解释... 问了LYN用的map函数做的,又去小小的学了map函数.... http://wenku.baidu.com/view/0b08cec ...

  2. 简单易懂的现代魔法——Play Framework攻略1

    哇哈哈,寒假结束啦,于是我又开新坑了....这次的主角可是大名鼎鼎的Play Framework!!那么闲话少说,开始攻略吧! 1.什么是Play Framework? 大名鼎鼎的play frame ...

  3. MessageBox.Show()如何换行

    MessageBox.Show("你好!\n\r可以使用", "换行");

  4. Makefile笔记

    一个简单的Makefile描述规则组成: TARGET...:PREREQUISITES... COMMANDS... ... target:规则的目标.通常是程序中间或者最后要生成的文件名,也可以是 ...

  5. *[hackerrank]Volleyball Match

    https://www.hackerrank.com/contests/w1/challenges/volleyball-match 此题不错,首先可以看出是DP,S(x, y)= S(x - 1, ...

  6. Android:打包apk

    右击项目->导出export next,完成相关信息填写将得到.apk文件,即可部署到手机上. 第一次: 然后打开目录就可以看到生成的apk,可以发布到各大市场上.

  7. FastDFS_v5.05安装配置

    废话不多讲,启动FastDFS文件服务器的命令是 #/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf #/usr/bin/fdfs_storaged /etc ...

  8. Struts2+JSON+JQUERY DEMO

    看到别人用了Struts2和JSON,自己也想练练手.记录下练习过程中遇到的问题,以便参考. 使用Maven新建项目: 先挂上pom.xml <project xmlns="http: ...

  9. android bitmap out of memory总结、心得

    setImageBitmap或setImageResource或BitmapFactory.decodeResource来设置一张大图,这些函数在完成decode后,最终都是通过java层的creat ...

  10. HDU4389:X mod f(x)(数位DP)

    Problem Description Here is a function f(x): int f ( int x ) { if ( x == 0 ) return 0; return f ( x ...