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. 表达式计算器(LL1文法)

    LL(1)文法求算数表达式的值递归子程序法 分析过程: 表达式文法G[E]:E->E+T|E-T|TT->T*F|T/F|T%F|FF->N^F|NN->(E)|NUM|+NU ...

  2. Yii框架入门教程(博客教程、权威指南、类手册)

    http://www.yiichina.com/ http://www.yiiframework.com/doc/blog/1.1/zh_cn/start.overviewhttp://www.yii ...

  3. input输入框默认文字,点击消失

    <input type="text" value="请输入用户名" onfocus="if(value=='请输入用户名') {value='' ...

  4. 【javascript】复制到剪贴板功能(支持目前各种浏览器)

    本demo支持各种浏览器复制,亲测可用(IE8,IE9,IE10,火狐,谷歌). 本demo中使用了ZeroClipboard(下载地址:https://github.com/zeroclipboar ...

  5. C#是怎么获取窗口标题的

    博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:C#是怎么获取窗口标题的.

  6. [caffe]深度学习之图像分类模型VGG解读

    一.简单介绍 vgg和googlenet是2014年imagenet竞赛的双雄,这两类模型结构有一个共同特点是go deeper.跟googlenet不同的是.vgg继承了lenet以及alexnet ...

  7. ThinkPHP函数详解:M方法

    M方法用于实例化一个基础模型类,和D方法的区别在于:1.不需要自定义模型类,减少IO加载,性能较好:2.实例化后只能调用基础模型类(默认是Model类)中的方法:3.可以在实例化的时候指定表前缀.数据 ...

  8. 在Java项目中整合Scala

    Scala是一个运行在Java JVM上的面向对象的语言.它支持函数编程,在语法上比Java更加灵活,同时通过Akka库,Scala支持强大的基于Actor的多线程编程.具有这些优势,使得我最近很想在 ...

  9. vs2010突然变慢解决方法

    方法一: 开始>>运行>>devenv.exe /resetuserdata

  10. android90 bind方式启动服务service调用service里的方法

    package com.itheima.banzheng; import com.itheima.banzheng.LeaderService.ZhouMi; import android.os.Bu ...