1 #include<iostream> 2 #include<set> 3 #include<algorithm> 4 #include<string> 5 using namespace std; 6 int main() 7 {//freopen("C:\Users\Sky\Desktop\1.in","r",stdin); 8 int n,i; 9 string s1,s2; 10 set<string>a,b; 11 set<string>::iterator it; 12 while(cin>>n,n) 13 { 14 for(i=1;i<=n;i++) 15 { 16 cin>>s1>>s2; 17 a.insert(s1); 18 b.insert(s2); 19 } 20 for(it=b.begin();it!=b.end();it++) 21 { 22 if(find(a.begin(),a.end(),*it)!=a.end()) 23 a.erase(*find(a.begin(),a.end(),*it)); 24 } 25 26 if(a.size()==1) 27 cout<<"Yes"<<endl; 28 else 29 cout<<"No"<<endl; 30 31 /* 32 for(it=a.begin();it!=a.end();it++) 33 cout<<*it<<endl;*/ 34 a.clear(); //清空容器 35 b.clear(); 36 } 37 return 0; 38 }