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. php 命名空间的目的

    php引入命名空间的目的,就是为了防止不同的文件 标识符同名的问题,比如类.函数.变量同名导致冲突的问题.这才是根本的根本,了解指点,带着这个观念去学习php命名空间的相关知识,就不会云里雾里了,会比 ...

  2. 网页解析的全过程(输入url到展示页面)

    1.用户输入网址,浏览器发起DNS查询请求 用户访问网页,DNS服务器(域名解析系统)会根据用户提供的域名查找对应的IP地址. 域名解析服务器是基于UDP协议实现的一个应用程序,通常通过监听53端口来 ...

  3. Ext4.1 , #Ext4.2

    在类中定义url 和 在参数中定义url不同 Ext4.1 和 Ext4.2 处理上有较大的区别

  4. 转 Could not create the view: An unexpected exception was thrown.问题解决

    转自:http://blog.csdn.net/shuangzixing520/article/details/35225105 今天打开Myeclipse10的时候,发现server窗口出现一堆问题 ...

  5. iOS10适配——错误:Code=3000

    error : Error Domain=NSCocoaErrorDomain Code=3000 "未找到应用程序的“aps-environment”的权利字符串" UserIn ...

  6. C++数据结构之map----第一篇

    摘要: 1 对于非标准类型的map,map 只需要重载小于号就可以了 2map结构初始化 map<string,double> g_lr=map<string,double>( ...

  7. ISP和IAP

    ISP(在系统编程)是一种不依赖于单片机自身软件的程序下载方式,特点是不需要从电路板上取下单片机,通过某种方式使单片机进入ISP模式,开放编程接口,由其使用的计算机将新的程序代码写入到存储器内.我们平 ...

  8. 用HTML 格式导出Excel

    只需按照如下格式写就可,在<head> 里面嵌套table,必须修改html的命名空间,加上一些描述.保存为xls文件 <html xmlns:x="urn:schemas ...

  9. Mac搭建Hadoop源码阅读环境

    1.本次Hadoop源码阅读环境使用的阅读工具是idea,Hadoop版本是2.7.3.需要安装的工具包括idea.jdk.maven.protobuf等 2.jdk,使用的版本是1.8版,在jdk官 ...

  10. margin负值-内秀篇

    zccst整理 margin系列之布局篇 margin系列之bug巡演(三) margin系列之bug巡演(二) margin系列之内秀篇(二) margin系列之bug巡演 margin系列之内秀篇 ...