Lweb and String

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

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
 
ccpc网赛的签到题,题意不是最长上升子序列
 //2016.8.16
#include<iostream>
#include<cstdio>
#include<set> using namespace std; set<int> st; int main()
{
int T, kase = ;
string s;
cin>>T;
while(T--)
{
cin>>s;
st.clear();
for(int i = ; i < s.size(); i++)
{
st.insert(s[i]);
}
printf("Case #%d: ", ++kase);
cout<<st.size()<<endl;
} return ;
}

HDU5842的更多相关文章

随机推荐

  1. 我的git常用命令

    git add . # 将所有修改过的工作文件提交暂存区 git commit -m ""

  2. Cocos2dx 3.1.1 学习笔记整理(3):逐帧动画

    以下代码是在cocos中使用,plist+png 还有SpriteBatchNode播放动画的代码,备份一下,以防git被墙: bool GameMain::init() { if( !Layer:: ...

  3. Java出现“Error configuring application listener of class...”类似的错误解决

    错误如下: Error configuring application listener of class com.jsoft.jblog.listener.SessionListener java. ...

  4. iOS navigationBar 的isTranslucent属性

    苹果文档: A Boolean value indicating whether the navigation bar is translucent (YES) or not (NO). The de ...

  5. 函数(swift)

    输入输出参数(In-Out Parameters) 如果你想要一个函数可以修改参数的值,并且想要在这些修改在函数调用结束后仍然存在,那么就应该把这个参数定义为输入输出参数(In-Out Paramet ...

  6. CentOS 6.4 x64 安装 配置 Redmine 2.4.1

    Redmine 安装配置 1. 安装Redmine 所需的依赖 首先安装 yaml wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz ...

  7. 关于div宽度和高度的100%设定

    设置DIV大小的有两个属性width和height,以前在学习DIV每次给DIV设置100%宽度或高度时都很迷惑,不明白这个100%的宽度(高度)到底有多宽有多高?这个100%是从哪里得到的从哪里继承 ...

  8. IP头,TCP头,UDP头,MAC帧头定义(转)

    源:IP头,TCP头,UDP头,MAC帧头定义 一.MAC帧头定义 /*数据帧定义,头14个字节,尾4个字节*/ typedef struct _MAC_FRAME_HEADER { ]; //目的m ...

  9. Java中的 List Set Map

    类层次关系如下: Collection ├List │├LinkedList │├ArrayList │└Vector │ └Stack └Set Map ├Hashtable ├HashMap └W ...

  10. HTML CSS基础(二)

    块元素和行内元素 HTML元素根据表现形式,可以分为2类: (1)块元素(block): (2)行内元素(inline): 任何HTML元素都属于这两类中的其中一类. 2.块元素特点: (1)独占一行 ...