UVA 644
#include<iostream> #include<string> using namespace std; int main() { string s[10]; string ss; int set=0,sum=0; while(cin>>ss) { cin.ignore(); if(ss=="9") { set++; int i,j,flag=0; for(i=0;i<sum;i++) { for(j=0;j<sum;j++) { if(i!=j) { if(s[j].find(s[i],0)==0) { flag++; break; } } } if(flag) break; } if(flag==0) cout<<"Set "<<set<<" is immediately decodable"<<endl; else cout<<"Set "<<set<<" is not immediately decodable"<<endl; for(i=0;i<sum;i++) s[sum]=""; sum=0; } s[sum]=ss; sum++; } return 0; }