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 |
这题折腾死我了,为啥用string总是TLE呢。60题刷水被呛了#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<algorithm> using namespace std; char a[100005][20]; int kik(int k) { int i,ans(0); for(i=0;i<strlen(a[k])&&i<strlen(a[k-1]);i++) { if(a[k][i]==a[k-1][i]) { ans++; } else break; }//cout<<ans<<endl; return ans; } int main() { int p(0),i(0),j; while(gets(a[i])) { if(i>0) { if(a[i][0]==a[i-1][0]) { if(p>=kik(i)) p=kik(i); else p++; } else p=0; } for(j=0;j<p;j++)printf(" "); printf("%s\n",a[i]); i++; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator