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 |
wh WA????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????/#include <iostream.h> #include <string.h> void main() { char a[201],b[201],c[401]; int n,i,j,k,m,stacki[201],stackj[201],top,num1[26],num2[26],num3[26]; cin>>n; for(m=1;m<=n;m++) { cin>>a>>b>>c; for(i=0;i<26;i++) num1[i]=num2[i]=num3[i]=0; for(i=0;i<strlen(a);i++) num1[a[i]-'a']++; for(i=0;i<strlen(b);i++) num2[b[i]-'a']++; for(i=0;i<strlen(c);i++) num3[c[i]-'a']++; bool sign=1; for(i=0;i<26&&sign;i++) if(num1[i]+num2[i]!=num3[i]) sign=0; if(sign==0) { cout<<"Data set "<<m<<": no"<<endl; continue; } top=k=i=j=0; while(k<strlen(c)) { if(c[k]==a[i]&&c[k]!=b[j]) { i++; k++; continue; } if(c[k]==b[j]&&c[k]!=a[i]) { j++; k++; continue; } if(c[k]==b[j]&&c[k]==a[i]) { stacki[top]=i; stackj[top++]=j; i++; k++; continue; } if(c[k]!=a[i]&&c[k]!=b[j]) { if(top--) { i=stacki[top]; j=stackj[top]+1; k=i+j; continue; } else { cout<<"Data set "<<m<<": no"<<endl; break; } } } if(k==strlen(c)) cout<<"Data set "<<m<<": yes"<<endl; } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator