problem DescriptionLweb 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 have 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 your 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)
InputThe 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 $ would n OT Exceed $10^5$.
OutputFor each of the test case, output A, "case #x: Y", where x was the case number, starting from 1. And y is the answer.
Sample Input2aabccacdeaa
Sample OutputCase #1:3Case #2:4The
code is as follows:
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5 6 using namespacestd;7 8 Chars[100010];9 intw[ -];Ten One intMain () A { - intT; - intD =0; the intsum; -scanf"%d",&t); - while(t--) - { +sum =0; -scanf"%s",&s); +Memset (W,0,sizeof(w)); A for(intI=0; I<strlen (s); i++) at { - if(w[s[i]-'a'] ==0){ -sum++; -w[s[i]-'a'] =1; -}Else - Continue; in } -printf"Case #%d:%d\n",++d,sum); to } + return 0; -}
Thinking Analysis:
The problem is test instructions. A is not out of the sample is confused! Example destroys a lifetime of 2333333, sometimes understanding is really more useful than knocking directly.
CCPC Network race, hdu_5842 Lweb and String