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. Sudoku Solver

    Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicated by th ...

  2. POJ 2912 Rochambeau(难,好题,枚举+带权并查集)

    下面的是从该网站上copy过来的,稍微改了一点,给出链接:http://hi.baidu.com/nondes/item/26dd0f1a02b1e0ef5f53b1c7 题意:有N个人玩剪刀石头布, ...

  3. java基础知识回顾之javaIO类--管道流PipedOutputStream和PipedIutputStream

    管道流(线程通信流):管道流的主要作用是可以进行两个线程间的通讯,分为管道输出流(PipedOutputStream).管道输入流(PipedInputStream),如果想要进行管道输出,则必须要把 ...

  4. Android 异步加载

    Android 4.0 后 貌似规定了 在主线程中不允许访问网络,在子线程中不允许修改UI. 否则会抛出NetworkOnMainThreadException 异常 解决办法: 采用继承 Async ...

  5. hdu 1005 java(System.out.println();与System.out.println(“\n”);)

    //package Main; import java.util.Scanner; public class Main { static int [][] mat=new int [2][2]; st ...

  6. Hibernate逍遥游记-第15章处理并发问题-002悲观锁

    1. 2. hibernate.dialect=org.hibernate.dialect.MySQLDialect hibernate.connection.driver_class=com.mys ...

  7. C++:成员运算符重载函数和友元运算符重载函数的比较

    5.2.4 成员运算符重载函数和友元运算符重载函数的比较 (1)对双目运算符而言,成员运算符重载函数参数表中含有一个参数,而友元运算符重载函数参数表中有两个参数:对于单目运算符而言,成员运算符重载函数 ...

  8. C++:对象声明

    (一)类与对象的关系: c++把类的变量叫做类的对象,对象也称类的实例 (二)对象的定义: 1.在声明类的同时,直接定义对象,即在声明类的右花括号“}”后,直接写出 属于该类的对象名表.例如:clas ...

  9. 修改linux命令行提示符路径显示

    命令显示行太长,影响观感,这样需要修改,具体方法: 1. 修改 ~/.bashrc,在最后一行添加: export PS1='[\u@\h\W]$' 其中\u是当前用户名,\h是当前主机名,\w显示当 ...

  10. MongoDB 安装和即基本操作

    http://www.mongodb.org/ Agile and Scalable MongoDB (from "humongous") is an open-source do ...