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 \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)

 
Input
The first line of the input contains the only integer
$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$.

 
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
代码如下:
 #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的更多相关文章

  1. 树形DP CCPC网络赛 HDU5834 Magic boy Bi Luo with his excited tree

    // 树形DP CCPC网络赛 HDU5834 Magic boy Bi Luo with his excited tree // 题意:n个点的树,每个节点有权值为正,只能用一次,每条边有负权,可以 ...

  2. (四面体)CCPC网络赛 HDU5839 Special Tetrahedron

    CCPC网络赛 HDU5839 Special Tetrahedron 题意:n个点,选四个出来组成四面体,要符合四面体至少四条边相等,若四条边相等则剩下两条边不相邻,求个数 思路:枚举四面体上一条线 ...

  3. 2018 CCPC网络赛

    2018 CCPC网络赛 Buy and Resell 题目描述:有一种物品,在\(n\)个地点的价格为\(a_i\),现在一次经过这\(n\)个地点,在每个地点可以买一个这样的物品,也可以卖出一个物 ...

  4. ccpc 网络赛 hdu 6155

    # ccpc 网络赛 hdu 6155(矩阵乘法 + 线段树) 题意: 给出 01 串,要么询问某个区间内不同的 01 子序列数量,要么把区间翻转. 叉姐的题解: 先考虑怎么算 \(s_1, s_2, ...

  5. 2018年 CCPC 网络赛 赛后总结

    历程:由于只是网络赛,所以今天就三开了.一开始的看题我看了d题,zz和jsw从头尾看起来,发现c题似乎可做,和费马大定理有关,于是和zz一起马上找如何计算勾股数的方法,比较慢的A掉了,而jsw此时看了 ...

  6. 2019杭电多校&CCPC网络赛&大一总结

    多校结束了, 网络赛结束了.发现自己还是太菜了,多校基本就是爆零和签到徘徊,第一次打这种高强度的比赛, 全英文,知识点又很广,充分暴露了自己菜的事实,发现数学还是很重要的.还是要多刷题,少玩游戏. 网 ...

  7. hdu 6152 : Friend-Graph (2017 CCPC网络赛 1003)

    题目链接 裸的结论题.百度 Ramsey定理.刚学过之后以为在哪也不会用到23333333333,没想到今天网络赛居然出了.顺利在题面更改前A掉~~~(我觉得要不是我开机慢+编译慢+中间暂时死机,我还 ...

  8. 2016中国大学生程序设计竞赛 - 网络选拔赛 1011 Lweb and String

    Problem Description Lweb has a string S. Oneday, he decided to transform this string to a new sequen ...

  9. hdu 5833 Zhu and 772002 ccpc网络赛 高斯消元法

    传送门:hdu 5833 Zhu and 772002 题意:给n个数,每个数的素数因子不大于2000,让你从其中选则大于等于1个数相乘之后的结果为完全平方数 思路: 小于等于2000的素数一共也只有 ...

随机推荐

  1. android实现图片平铺效果&WebView多点触控实现缩放

    1.图片平铺效果实现非常简单,只要在xml中添加一个 android:tileMode的属性就可以了.首先在drawable文件夹中添加自己的my.xml文件.代码: Java代码 <?xml ...

  2. lua 中pairs 和 ipairs区别

    lua 中pairs 和 ipairs区别 标准库提供了集中迭代器,包括迭代文件每行的(io.lines),迭代table元素的(pairs),迭代数组元素的(ipairs),迭代字符串中单词的 (s ...

  3. ambari安装过程中的问题汇总

    今天重新安装ambari过程中,遇到了几个问题,耗费了我很长时间,在此记录一下 ambari重新安装可参考我之前的一篇随笔 http://www.cnblogs.com/6tian/p/4097401 ...

  4. 怎么加 一个 hyperlink 到 e-mail template for CRM

    Recently I had a client inquire as to how one would insert a hyperlink into a CRM email template. Wh ...

  5. Redis 数据库结构设计

    Redis设计参考资料: http://my.oschina.net/fsmwhx/blog/152130 http://my.oschina.net/1123581321/blog/164288 h ...

  6. 掌握jQuery插件开发

    进行jQuery插件开发前,首先要知道两个问题:什么是jQuery插件?jQuery插件如何使用? 第一个问题,jQuery插件就是用来扩展jQuery原型对象的一个方法,简单来说就是jQuery插件 ...

  7. eclipse项目出现红色叉叉解决方案

    方法一:导入的文件被删除了.解决方法:右击项目名,在弹出的菜单中选择“Bulid Path”-->“configure build path”-->“Source”,找到已被删除的那个文件 ...

  8. Palindrome(poj3974)(manacher算法)

    http://poj.org/problem?id=3974 Palindrome Time Limit: 15000MSMemory Limit: 65536K Total Submissions: ...

  9. CentOS 配置httpd使局域网能够正常訪问

    [转载请注明出处: 钱国正的专栏http://blog.csdn.net/qianguozheng/article/details/37611859] 问题: 在CentOS上安装apache,配置好 ...

  10. java程序查不出数据来

    同样的错误,不可再犯第三次!!! 数据库中是char,里面带空格,但在pl/sql中这样写可以查出来.如下: select ipostid from product t where ipostid= ...