|
|
back to boardWhy TLE 1? Please help me I can't find my mistake # include <iostream> # include <string> using namespace std; int main() { int i,j,n,k,m; char a[6],temp[6],c; bool b[6],t,f=false; for(i=1;i<6;i++) b[i]=false; b[0]=true; t=true; cin>>n; cin.get(c); i=0; while(cin.get(c)) { if(c==EOF) break; if(c=='\n') { t=true; n--; if(n==0) break; if(b[i]) printf("YES\n"); else printf("NO\n"); for(i=1;i<6;i++) b[i]=false; b[0]=true; i=0; continue; } i=(i+1)%6; if(t) { a[i]=c; t=false; for(j=i-1;j>=i-6;j--) { if(b[(j+6)%6]) { k=j+1; m=0; t=true; for(;k<=i;k++) temp[m++]=a[(k+6)%6]; temp[m]='\0'; if( strcmp(temp,"in")==0 || strcmp(temp,"out")==0 || strcmp(temp,"one")==0 || strcmp(temp,"input")==0 || strcmp(temp,"puton")==0 || strcmp(temp,"output")==0) { b[i]=f=true; break; } } } if(!f) b[i]=false; f=false; } } if(b[i]) printf("YES\n"); else printf("NO\n"); return 0; } Edited by author 09.02.2009 23:58 Re: Why TLE 1? Just read the whole input and reverse it. this string is decoded very easy if it's read backward :) Re: Why TLE 1? Input from cin is VERY slow. Use faster reading functions (scanf(), gets(), ...) |
|
|