Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
怎么会是超时啊...........#include"iostream" using namespace std; #include"stdio.h" main() { int n,num[101]; cin>>n; for(int l=0;l<n;l++) { char str1[101],str2[101]; scanf("%s%s",str1,str2); int i,j,temp1=0,temp2; int count1=0,count2=0; // int len1=strlen(str1); // int len2=strlen(str2); for(i=0;i<strlen(str2);i++) { for(j=temp1;j<strlen(str1);j++) { if(str2[i]==str1[j]) { count1++; temp1=j+1; break; } } if(count1<=i)break; } temp2=strlen(str1)-1; for(int ii=0;ii<strlen(str2);ii++) { for(int jj=temp2;jj>=0;jj--) { if(str2[ii]==str1[jj]) { count2++; temp2=jj-1; break; } } if(count2<=ii)break; } if((count1==strlen(str2))||(count2==strlen(str2))) //cout<<"YES"<<endl; num[l]=1; else num[l]=0; } for(int kk=0;kk<n;kk++) { if(num[kk]==1) cout<<"YES"<<endl; else cout<<"NO"<<endl; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator