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;
}

 

posted @ 2012-04-28 11:54  open your eyes  阅读(175)  评论(0编辑  收藏  举报