标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 4367 Accepted Submission(s): 1265
#include <cstdio> #include <vector> #include <cstring> #include <algorithm> using namespace std; const int maxn=1e5+5; char s[maxn]; int dp[maxn]; bool vis[30]; int main(){ //freopen("data.in","r",stdin); int t,c=0; scanf("%d",&t); while(t--){ scanf("%s",s); memset(vis,0,sizeof(vis)); int len=0; int n=strlen(s); for(int i=0;i<n;i++) vis[s[i]-‘a‘+0]++; /* dp[1]=s[0]; for(int i=1;i<n;i++){ if(s[i]>dp[len]) dp[++len]=s[i]; else { int x= lower_bound(dp,dp+len+1,s[i])-dp; dp[x]=s[i]; } } */ for(int i=0;i<30;i++) if(vis[i]) len++; printf("Case #%d: %d\n",++c,len); } }
标签:
原文地址:http://www.cnblogs.com/acmtime/p/5790401.html