CCPC网络赛,HDU_5842 Lweb and String
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 \rightarrow 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)
$T, (1 \leq T \leq 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 $10^5$.
where x is the case number, starting from 1. And y is the answer.
#include <iostream>
#include <cstdio>
#include <cstring>
#include<cmath> using namespace std; char s[];
int w[]; int main()
{
int t;
int d = ;
int sum;
scanf("%d",&t);
while(t--)
{
sum = ;
scanf("%s",&s);
memset(w,,sizeof(w));
for (int i=;i<strlen(s);i++)
{
if (w[s[i]-'a'] == ){
sum++;
w[s[i]-'a'] = ;
}else
continue;
}
printf("Case #%d: %d\n",++d,sum);
}
return ;
}
思路解析:
这题就是题意的问题。A不出来都是被样例迷惑了!样例毁一生2333333,有时候理解真的比直接敲更有用。
CCPC网络赛,HDU_5842 Lweb and String的更多相关文章
- 树形DP CCPC网络赛 HDU5834 Magic boy Bi Luo with his excited tree
// 树形DP CCPC网络赛 HDU5834 Magic boy Bi Luo with his excited tree // 题意:n个点的树,每个节点有权值为正,只能用一次,每条边有负权,可以 ...
- (四面体)CCPC网络赛 HDU5839 Special Tetrahedron
CCPC网络赛 HDU5839 Special Tetrahedron 题意:n个点,选四个出来组成四面体,要符合四面体至少四条边相等,若四条边相等则剩下两条边不相邻,求个数 思路:枚举四面体上一条线 ...
- 2018 CCPC网络赛
2018 CCPC网络赛 Buy and Resell 题目描述:有一种物品,在\(n\)个地点的价格为\(a_i\),现在一次经过这\(n\)个地点,在每个地点可以买一个这样的物品,也可以卖出一个物 ...
- ccpc 网络赛 hdu 6155
# ccpc 网络赛 hdu 6155(矩阵乘法 + 线段树) 题意: 给出 01 串,要么询问某个区间内不同的 01 子序列数量,要么把区间翻转. 叉姐的题解: 先考虑怎么算 \(s_1, s_2, ...
- 2018年 CCPC 网络赛 赛后总结
历程:由于只是网络赛,所以今天就三开了.一开始的看题我看了d题,zz和jsw从头尾看起来,发现c题似乎可做,和费马大定理有关,于是和zz一起马上找如何计算勾股数的方法,比较慢的A掉了,而jsw此时看了 ...
- 2019杭电多校&CCPC网络赛&大一总结
多校结束了, 网络赛结束了.发现自己还是太菜了,多校基本就是爆零和签到徘徊,第一次打这种高强度的比赛, 全英文,知识点又很广,充分暴露了自己菜的事实,发现数学还是很重要的.还是要多刷题,少玩游戏. 网 ...
- hdu 6152 : Friend-Graph (2017 CCPC网络赛 1003)
题目链接 裸的结论题.百度 Ramsey定理.刚学过之后以为在哪也不会用到23333333333,没想到今天网络赛居然出了.顺利在题面更改前A掉~~~(我觉得要不是我开机慢+编译慢+中间暂时死机,我还 ...
- 2016中国大学生程序设计竞赛 - 网络选拔赛 1011 Lweb and String
Problem Description Lweb has a string S. Oneday, he decided to transform this string to a new sequen ...
- hdu 5833 Zhu and 772002 ccpc网络赛 高斯消元法
传送门:hdu 5833 Zhu and 772002 题意:给n个数,每个数的素数因子不大于2000,让你从其中选则大于等于1个数相乘之后的结果为完全平方数 思路: 小于等于2000的素数一共也只有 ...
随机推荐
- JavaScript删除数组重复元素的5个高效算法
之前一段时间一直在准备面试, 因而博客太久没更新: 现在基本知识点都复习完毕, 接下来就分享下 面试的一些常见问题: 去正规的互联网公司笔试.面试有很大的概率会碰到 使用javascript实现数组去 ...
- mongoDB中的连接池(转载)
一.mongoDB中的连接池 刚上手MongoDB,在做应用时,受以前使用关系型数据库的影响,会考虑数据库连接池的问题! 关系型数据库中,我们做连接池无非就是事先建立好N个连接(connection) ...
- bootstrap多层模态窗
<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8&quo ...
- github上值得关注的前端项目
https://segmentfault.com/a/1190000002804472
- 【面试虐菜】—— MongoDB知识整理
为什么我们要使用MongoDB? 特点: 高性能.易部署.易使用,存储数据非常方便.主要功能特性有: 面向集合存储,易存储对象类型的数据. 模式自由. 支持动态查询. 支持完全索引,包含内部对象. 支 ...
- hdu 4635 Strongly connected(Tarjan)
做完后,看了解题报告,思路是一样的.我就直接粘过来吧 最终添加完边的图,肯定可以分成两个部X和Y,其中只有X到Y的边没有Y到X的边,那么要使得边数尽可能的多,则X部肯定是一个完全图,Y部也是,同时X部 ...
- mysql delete from
delete a from #ta a where exists (select 1 from #tb b where a.id=b.id)
- SPOJ 3273 - Order statistic set , Treap
点击打开链接 题意: 集合S支持一下四种操作: INSERT(S,x) : 假设S中没有x,则插入x DELETE(S,x): 假设S中有x,则删除x K-TH(S): ...
- Spring.NET学习笔记
http://www.cnblogs.com/GoodHelper/archive/2009/11/20/SpringNet_Index.html
- 进程控制之wait3和wait4函数
大多数UNIX系统实现提供了另外两个函数wait3和wait4.它们提供的功能比POSIX.1函数wait.waitpid和waitid所提供的功能要多一个,这与附加参数rusage有关.该参数要求内 ...