|
|
back to boardWhy crash Posted by keivan 16 Nov 2010 18:32 my voids don't give any input, but still it says crashed This is my code: #include<iostream> #include<string> using namespace std; long int n,len; string a; string ch; long int pp,xx,ii,st,x; bool st_match() { pp=ch.length(); if(xx+pp>len) return false; for(ii=xx;ii<xx+pp;ii++) if(a[ii]!=ch[ii-xx]) return false; return true; } bool p; void DFS() { if(p) return ; if(x==len) { p=true; cout<<"YES"<<endl; return ; } st=xx; xx=x; ch="one"; if(st_match()){x+=3;DFS();x-=3;} ch="puton"; if(st_match()){x+=5;DFS();x-=5;} ch="input"; if(st_match()){x+=5;DFS();x-=5;} ch="in"; if(st_match()){x+=2;DFS();x-=2;} ch="output"; if(st_match()){x+=6; DFS(); x-=6;} ch="out"; if(st_match()){x+=3; DFS(); x-=3;} xx=st; return ; } int main(){ cin>>n; for(int i=0;i<n;i++) { cin>>a; p=false; len=a.length(); x=0; DFS(); if(!p) cout<<"NO"<<endl; } cin>>n; return 0; } Edited by author 16.11.2010 18:32 |
|
|