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 |
为什么是RE呢??#include <iostream> #include <fstream> using namespace std; int main(){ // ifstream cin("data.txt"); int testcase,tc; cin>>testcase; for(tc=1;tc<=testcase;tc++){ int n,i,j,k; char a[150][1500]; cin>>n; for(i=0;i<n;i++){ cin>>a[i]; // cout<<a[i]<<endl; } // cout<<endl; int res=0; int len=strlen(a[0]); bool search=false; for(i=len;i>0&&!search;i--){ for(j=0;j<=len-i&&!search;j++){ //以j作为开始 char tmps[1500]; int s=0; for(k=j;k<j+i;k++){ tmps[s++]=a[0][k]; } tmps[s]='\0'; // cout<<"tmps="<<tmps<<endl; int x,y; bool find=true; for(k=1;k<n&&find;k++){ for(x=0;x<=strlen(a[k])-s;x++){ // cout<<a[k]<<" "<<x<<" "<<strlen(a[k])-1-x<<endl; int p1=0,p2=x; while(a[k][p2]==tmps[p1]){ p2++; p1++; if(p1==s)break; } if(p1==s)break; p1=0;p2=strlen(a[k])-1-x; while(a[k][p2]==tmps[p1]){ p1++; p2--; if(p1==s)break; } if(p1==s)break; } if(x==(strlen(a[k])-s+1)){ find=false; break; } } if(k==n&&find){ cout<<i<<endl; search=true; break; } } } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator