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 |
why wa?#include<string> #include<cstdio> #include<iostream> #include<algorithm> #define Max 1000 using namespace std; typedef struct { string c; int l; }stcode; stcode code[Max]; int icount; int test; bool avail; bool cmp(stcode a,stcode b) { return a.l<b.l; } int main() { icount=test=0; avail=true; char strin[200]; string str; int i,j; while(EOF!=scanf("%s",strin)) { str=strin; if(str=="9") { sort(code,code+icount,cmp); for(i=0;i<icount;i++) { for(j=i+1;j<icount;j++) { if(code[i].c==code[j].c.substr(0,code[i].l)) { avail=false; goto endit; } } } endit: test++; cout<<"Set "<<test<<" is "; if(!avail) cout<<"not "; cout<<"immediately decodable"<<endl; icount=0; continue; } else { code[icount].c=str; code[icount].l=str.size(); icount++; } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator