标签:
3 aaa ababc abklmncdefg
1 3 7
#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; char s[10001]; int dp[10001]; int main(){ int n; scanf("%d",&n); while(n--){ scanf("%s",s); int len=strlen(s),i,j; for(i=0;i<len;++i) dp[i]=1; for(i=1;i<len;++i){ for(j=0;j<i;++j){ if(s[j]<s[i]&&dp[j]+1>dp[i]){ dp[i]=dp[j]+1; } } } int maxn=dp[0]; for(i=1;i<len;++i) maxn=max(maxn,dp[i]); printf("%d\n",maxn); } return 0; }
标签:
原文地址:http://www.cnblogs.com/hpuwyf/p/4401107.html