HDU 5842 Lweb and String(Lweb与字符串)
HDU 5842 Lweb and String(Lweb与字符串)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Problem Description - 题目描述
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
输入的第一行只有一个整数T,(≤T≤)。 随后T行,每行都有一个仅由小写字母组成的字符串S,S的长度不超过10^。
CN
Output - 输出
对于每组测试用例,输出一行"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与字符串)的更多相关文章
- HDU 3336 Count the string 查找匹配字符串
Count the string Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- HDU 5842 Lweb and String (水题)
Lweb and String 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5842 Description Lweb has a string S ...
- HDU 5842 Lweb and String 水题
Lweb and String 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5842 Description Lweb has a string S ...
- HDU 5842 Lweb and String
Lweb and String Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
- Lweb and String 超级大水题
Lweb and String Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
- HDU 3973 AC's String 字符串哈希
HDU 3973 通过哈希函数将一个字符串转化为一个整数,通过特定的方式可以使得这个哈希值几乎没有冲突(这就是关键之处,几乎没有视为没有= =!, 其实也可以考虑实现哈希冲突时的处理,只是这道题没必要 ...
- hdu 4850 Wow! Such String! 欧拉回路
作者:jostree 转载请注明出处 http://www.cnblogs.com/jostree/p/4080264.html 题目链接:hdu 4850 Wow! Such String! 欧拉回 ...
- hdu 3553 Just a String (后缀数组)
hdu 3553 Just a String (后缀数组) 题意:很简单,问一个字符串的第k大的子串是谁. 解题思路:后缀数组.先预处理一遍,把能算的都算出来.将后缀按sa排序,假如我们知道答案在那个 ...
- HDU 4850 Wow! Such String!(欧拉道路)
HDU 4850 Wow! Such String! 题目链接 题意:求50W内的字符串.要求长度大于等于4的子串,仅仅出现一次 思路:须要推理.考虑4个字母的字符串,一共同拥有26^4种,这些由这些 ...
随机推荐
- Larbin初试
前阵子找工作的时候经常会看到epoll多路复用的知识点,无奈自己一点都不懂.慌忙之际也只能去了解个大概.所以最近闲下来之后想要基于epoll机制实现一个比较有用的东西,刚好最近又想爬些东西,希望这次能 ...
- Careercup | Chapter 8
8.2 Imagine you have a call center with three levels of employees: respondent, manager, and director ...
- Fiddler-010-网络延时应用小技巧-模拟低网速环境
在日常的网络测试中,经常需要测试网络超时或在网络传输速率不佳的情况的应用场景,而与此同时我们有时手边资源有限,实现在各种真实网络(2G\3G)环境下测试有些局限性.其实 fiddler 已经提供了类似 ...
- Spring框架简介 Spring Framework Introduction
Introduction The Spring Framework provides a comprehensive programming and configuration model for m ...
- GIt的命令
Git 命令 1,git init初始化当前文件夹为git仓库的根目录 2.git commit提交到本地仓库 3.git push origin master 提交到服务器 4.git log 查看 ...
- HTML报表日期格式不对 导致报错ORA-01861: 文字与格式字符串不匹配
PROCEDURE MAIN(ERRBUF OUT VARCHAR2, RETCODE OUT VARCHAR2, P_CUSTOMER_ID IN VARCHAR2, P_PERSON_ID IN ...
- windows环境下Django安装配置
--python下载 https://www.python.org/downloads/ --pip 下载 https://pypi.python.org/pypi/pip --pip 安装及路径 解 ...
- Android应用权限管理总结
访问登记属性 android.permission.ACCESS_CHECKIN_PROPERTIES ,读取或写入登记check-in数据库属性表的权限 获取错略位置 android.permi ...
- ScrollView和listview的冲突问题,关于宽度,和滑动
只需要重新listview即可 package com.exmple.listscrow; import java.util.logging.LogManager; import android.co ...
- 谈谈JDK线程的伪唤醒
在JDK的官方的wait()方法的注释中明确表示线程可能被"虚假唤醒",JDK也明确推荐使用while来判断状态信息.那么这种情况的发生的可能性有多大呢? 使用生产者消费者模型来说 ...