ACM ZJU 1808

来源:互联网 发布:开淘宝店要求 编辑:程序博客网 时间:2024/05/23 01:59

 

#include <iostream>
#include 
<string>
#include 
<vector>
//#include <algorithm>
using namespace std;

int main()
{
    
int count = 1;
    
string s;
    
while(cin>>s)
    {
        vector
<string> svec;
        
while(s != "9")
        {
            svec.push_back(s);    
            cin
>>s;    
        }
        
bool tag = false;
        
for(vector<string>::iterator it = svec.begin(); it != svec.end(); ++it)
        {
            
for(vector<string>::iterator k = (it+1); k != svec.end(); ++k)
            {
                tag 
= true;
                
string s1= *it;
                
string s2 = *k;
                
int t1 = s1.size();
                
int t2 = s2.size();
                
int minnumber = (t1>=t2 ? t2:t1);
                
                
for(int i=0; i<minnumber; ++i)
                {
                    
if (s1[i] != s2[i])
                    {
                        tag 
= false;
                        
break;
                    }
                }
                
if (tag == true)
                {
                    
break;
                }
            }
            
            
if (tag == true)
            {
                
break;
            }
        }
        
if (tag)
        {
            cout
<<"Set "<<count<<" is not immediately decodable"<<endl;
        }
        
else
        {
            cout
<<"Set "<<count<<" is immediately decodable"<<endl;
        }
        count
++;
    }
    
return 0;
}
原创粉丝点击