Create 5842.cpp

pull/35/head
Kirigaya Kazuto 2016-08-14 17:21:28 +08:00 committed by GitHub
parent 56be801fcc
commit f0ee2f9bec
1 changed files with 29 additions and 0 deletions

29
HDOJ/5842.cpp Normal file
View File

@ -0,0 +1,29 @@
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;
#define N 199999
char b[N];
char a[N];
int LIS( int n) {
int len = 1; b[0] = a[0];
for (int i = 1; i < n; i++) {
b[a[i] > b[len - 1] ? len++ : lower_bound(b, b + len, a[i]) - b] = a[i]; //·Ç½µ»»Îª>=ºÍupper_bound
}
return len;
}
int main()
{
int t;
scanf("%d%*c",&t);
for(int test=0;test<t;++test)
{
gets(a);
int L=strlen(a);
sort(a,a+L);
int ans=LIS(L);
printf("Case #%d: %d\n",test+1,ans);
}
return 0;
}