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 \rightarrow 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 \leq T \leq 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 $10^5$.

 
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
代码如下:
 #include <iostream>
#include <cstdio>
#include <cstring>
#include<cmath> using namespace std; char s[];
int w[]; int main()
{
int t;
int d = ;
int sum;
scanf("%d",&t);
while(t--)
{
sum = ;
scanf("%s",&s);
memset(w,,sizeof(w));
for (int i=;i<strlen(s);i++)
{
if (w[s[i]-'a'] == ){
sum++;
w[s[i]-'a'] = ;
}else
continue;
}
printf("Case #%d: %d\n",++d,sum);
}
return ;
}

思路解析:

这题就是题意的问题。A不出来都是被样例迷惑了!样例毁一生2333333,有时候理解真的比直接敲更有用。

最新文章

  1. Python之路第一课Day4--随堂笔记(迭代生成装饰器)
  2. linux常用工具链接
  3. 05 技术内幕 T-SQL 查询读书笔记(第四章)
  4. Spring中@Async注解实现“方法”的异步调用
  5. {Reship}{ListView}C# ListView用法详解
  6. ios-chart 不支持渐变的底色 --- 后面支持了渐变
  7. JS模板引擎 :ArtTemplate (1)
  8. iOS 定位系统 知识
  9. GLSL实现Fresnel And Chromatic aberration 【转】
  10. C++ C++ 控制台程序 设置图标
  11. BZOJ3362 [Usaco2004 Feb]Navigation Nightmare 导航噩梦
  12. Git 少用 Pull 多用 Fetch 和 Merge(转)
  13. js----数组处理之splice(有js原始addClass方法哦)
  14. 解决Plugin is too old,please update to a more recent version,or set ANDROID_DAILY_OVERRIDE..
  15. js三部曲---预编译
  16. 【Teradata】磁盘碎片整理(ferret工具)
  17. css3的transform,translate和transition之间的区别与作用
  18. java—在dbutils中处理事务与不确定条件的查询(46)
  19. 二进制GCD算法解析
  20. Download link in response body does not work--待解决

热门文章

  1. weka 集成学习
  2. POJ1155 - TELE(树形DP)
  3. Weblogic 集群部署说明 --转
  4. pes and ts stream, how to convert
  5. 第一个php网页
  6. iOS中事件的传递和响应者链条
  7. html传參中?和&amp;amp;
  8. 【转】C++的面象对象总结
  9. MySQL启动和关闭服务命令
  10. linux上配置jdk+Apache