#include <iostream>
#include <cstdio>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
const int N=260;
string str[N];
bool ffflag=true;
struct Node{
string num;
string dir;
};
bool cmp(Node a,Node b)
{
if(a.dir.length()==b.dir.length()){
if(a.dir==b.dir) ffflag=false;
return a.dir<b.dir;
}
return a.dir.length()<b.dir.length();
}
int main()
{
string str[N];
while(cin>>str[0]){
ffflag=true;
Node point[N];
int counter=1;
if(str[0]=="()"){
cout<<"not complete"<<endl;
continue;
}
while(cin>>str[counter]){
if(str[counter]=="()") break;
counter++;
}
int i,j,k;
for(i=0;i<counter;i++){
for(j=1;j<str[i].length();j++){
if(str[i][j]==',') break;
}
point[i].num=str[i].substr(1,j-1);
for(k=j;k<str[i].length();k++){
point[i].dir=str[i].substr(j+1,str[i].length()-j-2);
if(point[i].dir.length()==0) point[i].dir=" ";
}
}
sort(point,point+counter,cmp);
bool flag=true,fflag=false;
for(i=0;i<counter;i++){
if(point[i].dir.length()>1){
flag=false;
string s=point[i].dir.substr(0,point[i].dir.length()-1);
for(j=0;j<counter;j++){
if(point[j].dir==s){
flag=true;
break;
}
}
if(flag==false) break;
}
if(point[i].dir.length()==1){
if(point[i].dir==" "){
fflag=true;
}
}
}
if(!flag|| !fflag || !ffflag) cout<<"not complete";
else{
for(i=0;i<counter;i++){
cout<<point[i].num;
if(i<counter-1){
cout<<" ";
}
}
}
cout<<endl;
}
return 0;
}
uva122-Trees on the level
最新推荐文章于 2020-07-17 23:58:25 发布