南阳理工oj
数据比较弱。。。
#include<iostream>#include<cstring>#define MAX_SIZE 10002using namespace std;char str[MAX_SIZE];int  cost[MAX_SIZE];int main(){	int t;	int len;	cin>>t;	char c;	while(t--)	{		cin>>str;		memset(cost,0,sizeof(cost));		len=strlen(str);	    cost[len-1]=1;	    c=str[len-1];	    for(int j=len-2;j>=0;j--)		{			int temp=j+1;			int maxnum=0;		    for(;temp<len;temp++)		    {		    	if(str[j]<str[temp]&&cost[temp]>maxnum)		    	{		    		maxnum=cost[temp];		    				    						}		    			    				}			cost[j]=maxnum+1;		    		}		int maxnum=-1;		for(int j=0;j<len;j++)		{		//cout<<cost[j]<<" ";			if(cost[j]>maxnum)			maxnum=cost[j];		}		cout<<maxnum<<endl;	}	}
新闻热点
疑难解答