Lweb and String

题目连接:

http://acm.hdu.edu.cn/showproblem.php?pid=5842

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→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≤T≤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 105.

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

Hint

题意

给你一个字符串,你可以把字符变成数字,然后让你构造一下,使得LIS最长是多少

题解:

其实就是字母个数,这个很显然嘛。

代码

#include<bits/stdc++.h>
using namespace std; int cas;
string s;
int cnt[26];
int main(){
int t;scanf("%d",&t);
while(t--){
cin>>s;
int ans = 0;
memset(cnt,0,sizeof(cnt));
for(int i=0;i<s.size();i++){
cnt[s[i]-'a']++;
if(cnt[s[i]-'a']==1)ans++;
}
printf("Case #%d: %d\n",++cas,ans);
}
}

HDU 5842 Lweb and String 水题的更多相关文章

  1. HDU 5842 Lweb and String(Lweb与字符串)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  2. HDU 5842 Lweb and String (水题)

    Lweb and String 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5842 Description Lweb has a string S ...

  3. HDU 5842 Lweb and String

    Lweb and String Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)T ...

  4. HDU 5578 Friendship of Frog 水题

    Friendship of Frog Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...

  5. HDU 5590 ZYB's Biology 水题

    ZYB's Biology Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid ...

  6. HDU 5538 L - House Building 水题

    L - House Building Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...

  7. HDOJ/HDU 1328 IBM Minus One(水题一个,试试手)

    Problem Description You may have heard of the book '2001 - A Space Odyssey' by Arthur C. Clarke, or ...

  8. HDOJ(HDU) 2090 算菜价(简单水题、)

    Problem Description 妈妈每天都要出去买菜,但是回来后,兜里的钱也懒得数一数,到底花了多少钱真是一笔糊涂帐.现在好了,作为好儿子(女儿)的你可以给她用程序算一下了,呵呵. Input ...

  9. HDOJ(HDU) 1555 How many days?(水题)

    Problem Description 8600的手机每天消费1元,每消费K元就可以获赠1元,一开始8600有M元,问最多可以用多少天? Input 输入包括多个测试实例.每个测试实例包括2个整数M, ...

随机推荐

  1. UVALive 2218 Triathlon

    https://vjudge.net/problem/UVALive-2218 题意: 铁人三项比赛,每项比赛长度未定,已知每个选手每项比赛的平均速度. 设计每项比赛的长度,让其中某个特定选手获胜. ...

  2. bzoj千题计划192:bzoj1569: [JSOI2008]Blue Mary的职员分配

    http://www.lydsy.com/JudgeOnline/problem.php?id=1569 dp[i][j][a][b] 表示i个职员,发广告状态为j,已有金钱a,声誉b的最少天数 j= ...

  3. cmd 概览---- 转

    打开"运行"对话框(Win+R),输入cmd,打开控制台命令窗口... 也可以通过cmd /c 命令 和 cmd /k 命令的方式来直接运行命令 注:/c表示执行完命令后关闭cmd ...

  4. 关于Cookie跨域的问题

    Cookie是一个伟大的发明,它允许Web开发者保留他们的用户的登录状态.但是当你的站点有一个以上的域名时就会出现问题了.在Cookie规范上说,一个cookie只能用于一个域名,不能够发给其它的域名 ...

  5. hadoop - hdfs 基础操作

    hdfs --help # 所有参数 hdfs dfs -help # 运行文件系统命令在Hadoop文件系统 hdfs dfs -ls /logs # 查看 hdfs dfs -ls /user/ ...

  6. linux下常用FTP命令 上传下载文件【转】

    1. 连接ftp服务器 格式:ftp [hostname| ip-address]a)在linux命令行下输入: ftp 192.168.1.1 b)服务器询问你用户名和密码,分别输入用户名和相应密码 ...

  7. selenium之 chromedriver与chrome版本映射表(更新至v2.34)

    看到网上基本没有最新的chromedriver与chrome的对应关系表,便兴起整理了一份如下,希望对大家有用: chromedriver版本 支持的Chrome版本 v2.34 v61-63 v2. ...

  8. windows中连接hive-客户端

    参考连接:http://lxw1234.com/archives/2016/09/723.htm 这里主要介绍:Oracle SQL Developer 1. 下载,免安装包 SQL Develope ...

  9. C#操作Mongo进行数据读写

    C#操作MongoHelp类 using System; using System.Collections.Generic; using System.Linq; using System.Web; ...

  10. Ibatis.Net 数据库操作学习(四)

    一.查询select 还记得第一篇示例中是如何读出数据库里3条数据的吗?就是调用了一个QueryForList方法,从方法名就知道,查询返回列表. 1.QueryForList  返回List< ...