Lweb and String 超级大水题
Lweb and String
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 261 Accepted Submission(s): 174
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)
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.
aabcc
acdeaa
Case #2: 4
#include<stdio.h>
#include<string.h>
#define N 10000006
char s[N];
int a[N];
int main(void)
{
int t, ans, i, j;
scanf("%d", &t);
j = 0;
while(t--)
{
j++;
ans = 0;
memset(a, 0, sizeof(a));
scanf("%s", s);
int n = strlen(s);
for(i = 0; i < n; i++)
a[s[i] - 'a' + 1]++;
for(i = 1; i <= 26; i++)
{
if(a[i])//判断26个英文字母是否出现过, 出现过长度就加1.
ans++;
}
printf("Case #%d: %d\n", j, ans);
}
}
Lweb and String 超级大水题的更多相关文章
- HDU 5842 Lweb and String (水题)
Lweb and String 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5842 Description Lweb has a string S ...
- hdu 1228 A+B 字符串处理 超级大水题
中文意思不解释. 很水,我本来想用switch处理字符串,然后编译不通过...原来switch只能处理整数型的啊,我都忘了. 然后就有了很挫的一大串if代码了... 代码: #include < ...
- hdu 4548 美素数 超级大水题
美素数 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) Total Submis ...
- hdu 1229 超级大水题
Time Limit: 1000MS Memory Limit: 32768KB 64bit IO Format: %I64d & %I64u Submit Status Desc ...
- HDU 5842 Lweb and String 水题
Lweb and String 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5842 Description Lweb has a string S ...
- PAT甲题题解-1101. Quick Sort (25)-大水题
快速排序有一个特点,就是在排序过程中,我们会从序列找一个pivot,它前面的都小于它,它后面的都大于它.题目给你n个数的序列,让你找出适合这个序列的pivot有多少个并且输出来. 大水题,正循环和倒着 ...
- PAT甲题题解-1117. Eddington Number(25)-(大么个大水题~)
如题,大水题...贴个代码完事,就这么任性~~ #include <iostream> #include <cstdio> #include <algorithm> ...
- [BFS,大水题] Codeforces 198B Jumping on Walls
题目:http://codeforces.com/problemset/problem/198/B Jumping on Walls time limit per test 2 seconds mem ...
- HDU 5842 Lweb and String(Lweb与字符串)
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...
随机推荐
- Python解析json字符串,json字符串用法
json数据简介 json数据是一个轻量级的数据交换格式,采用完全独立于语言的文本格式,这些特性使json称为理想的数据交换语言,易于人阅读和编写,同时易于机器解析和生成. json中的字符集必须是U ...
- 【原创】Dubbo 2.7.5在线程模型上的优化
这是why技术的第30篇原创文章 这可能是全网第一篇解析Dubbo 2.7.5里程碑版本中的改进点之一:客户端线程模型优化的文章. 先劝退:文本共计8190字,54张图.阅读之前需要对Dubbo相关知 ...
- Flask蓝图(Blueprint)
一.作用 1.目录结构划分 2.url添加前缀 url_prefix 3.应用特殊装饰器,在该蓝图定义的特殊装饰器,只在改蓝图的起效 二.简单示例 1.创建一个项目文件 2.创建一个同名的python ...
- 6.反编译 java---class (字节码文件)---反编译(IDEA):
- 一张图快速上手Xmind思维导图
使用软件:Xmind8 pro版(可在网上找破解版),应用广泛,功能强大
- MySql主要性能指标说明
在项目当中数据库一般都会成为主要的性能与负载瓶颈,那么针对数据库各项性能指标的监控与对应的优化是开发与运维人员需要面对的主要工作,而且这部分的工作会贯穿项目从开发到运行的整个周期里. 这篇文章中我们对 ...
- Tomcat 9 与JDK 8 的安装与配置
Tomcat 9的安装与配置 解压压缩包,我的解压路径是:D:\Program Files\Java 注意:这里tomcat压缩包不能解压到C盘,否则会因为C盘文件夹访问权限授权问题,没法解决后面出现 ...
- 玩转Django2.0---Django笔记建站基础七(表单与模型)
第七章 表单与模型 表单是搜集用户数据信息的各种表单元素的集合,作用是实现网页上的数据交互,用户在网站输入信息,然后提交到网站服务器端进行处理(如数据录入和用户登录.注册等). 用户表单是web开发的 ...
- Easy C 编程 in Linux
入坑Ubuntu有4,5天了,当时各种不习惯,但现在渐渐喜欢上了这种简单大方的显示界面和快速高效的命令行模式,各种没有的功能也都有网页版,非常不错呢. 现在最让我感到神奇之处,便是Linux的C编程是 ...
- js----UTC时间于本地时间相差8小时问题
js----UTC时间于本地时间相差8小时问题 js获取周几有两个方法getDay() getUTCDay(),但是它们是有区别的,前者返回的本地时间,后者返回的UTC时间,一般情况下,两者相差8个小 ...