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

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

 

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)
Lweb有个字符串S

某天,他决定用原串弄腾出一个新串。

你需要帮他确定变化的形式,使得新串具有最长的LIS(严格递增)。

你需要把字符串中的每种字母转化成一个数字。

A是S的字母集合,B是自然数集合。

任意映射 f:A→B 都是合法变动。

比如说,一个字符串“aabc”,A={a,b,c},你可以转换成“   ”,新串的LIS长度为3。

现在帮帮Lweb找出你能从S中获得的最长LIS。

LIS:最长升序子序列。(https://en.wikipedia.org/wiki/Longest_increasing_subsequence)

CN

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.
输入的第一行只有一个整数T,(≤T≤)。

随后T行,每行都有一个仅由小写字母组成的字符串S,S的长度不超过10^。

CN

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.
对于每组测试用例,输出一行"Case #x: y",x表示测试用例的编号,从1开始。y为答案。

CN

Sample Input - 输入样例

2
aabcc
acdeaa

Sample Output - 输出样例

Case #1: 3
Case #2: 4

题解

  字母转数字,然后求最长升序子序列的长度。

  因此映射关系是随意自定的,因此题目只要求字符串中的字母种类数量即可。

代码 C++

 #include <cstdio>
#include <cstring>
char data[], inUS[];
int main(){
int t, i, j, opt;
scanf("%d ", &t);
for (i = ; i <= t; ++i){
gets(data);
memset(inUS, , sizeof(inUS)); opt = ;
for (j = ; data[j]; ++j){
if (~inUS[data[j]]) ++opt, --inUS[data[j]];
}
printf("Case #%d: %d\n", i, opt);
}
return ;
}

HDU 5842 Lweb and String(Lweb与字符串)的更多相关文章

  1. HDU 3336 Count the string 查找匹配字符串

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

  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. HDU 5842 Lweb and String

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

  5. Lweb and String 超级大水题

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

  6. HDU 3973 AC's String 字符串哈希

    HDU 3973 通过哈希函数将一个字符串转化为一个整数,通过特定的方式可以使得这个哈希值几乎没有冲突(这就是关键之处,几乎没有视为没有= =!, 其实也可以考虑实现哈希冲突时的处理,只是这道题没必要 ...

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

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

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

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

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

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

随机推荐

  1. Final-阶段站立会议1

    组名:天天向上 组长:王森 组员:张政.张金生.林莉.胡丽娜 代码地址:HTTPS:https://git.coding.net/jx8zjs/llk.git SSH:git@git.coding.n ...

  2. Objective-C 在Categroy中创建属性(Property)

    Objective-c中category是不能直接创建属性的,这时候我们要用到Objc的runtime来实现 用到的方法有两个 一个是get方法 一个set方法 //get方法objc_getAsso ...

  3. youtube视频下载

    开你的电脑,然后打开你的浏览器,浏览器可以是IE.Chrome.Firefox等等   在浏览器中输入这个网址:en.savefrom.net,点击Enter键,进入这个网页:   打开你需要下载的y ...

  4. 中兴F412光猫超级密码破解、破解用户限制、关闭远程控制、恢复路由器拨号

    不少家庭都改了光纤入户,那肯定少不了光猫的吧.今天以中兴F412光猫为例介绍下此型号光猫超级密码的破解方法.一.F412超级密码破解方法1.运行CMD,输入telnet 192.168.1.1: 2. ...

  5. centos 下 安装zookpeer

    tar xvf zookeeper-3.4.6.tar.gz cd /usr/local/zookpeer/ mkdir /var/zookpeer mkdir /var/zookpeer/data ...

  6. 打开VS调试不进入开发的网站直接跳转到主页

    重启了熟悉有卸载IE11的,搞了好几个小时 最后把电脑管家里的锁定主页打开就好了! 很久之后  我再锁上  也没有这问题了

  7. 转:"在已损坏了程序内部状态的XXX.exe 中发生了缓冲区溢出"的一种可能原因

    我的问题跟原作者的问题差不多.头文件和DLL不匹配导致的. 原文链接:http://blog.csdn.net/u012494876/article/details/39030887 今天软件突然出现 ...

  8. css3渐变色彩

    CSS3 Gradient 分为线性渐变(linear)和径向渐变(radial).由于不同的渲染引擎实现渐变的语法不同,这里我们只针对线性渐变的 W3C 标准语法来分析其用法,其余大家可以查阅相关资 ...

  9. ubuntu 下安装 wxpython2.8

    echo "deb http://archive.ubuntu.com/ubuntu wily main universe" | sudo tee /etc/apt/sources ...

  10. Adobe CS6 全系列官方下载地址 (迅雷无效) Win Mac

    https://helpx.adobe.com/x-productkb/policy-pricing/cs6-product-downloads.html CS6 Design & Web P ...