标签:
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 12031 Accepted Submission(s): 5583
1 #include<bits/stdc++.h> 2 using namespace std; 3 map<string,int>in; 4 map<string,map<string,int> >mp; 5 map<int,string>dis; 6 map<string,int>pis; 7 queue<string> q; 8 int main() 9 { 10 int n; 11 int coun; 12 while(scanf("%d",&n)!=EOF) 13 { 14 if(n==0) 15 break; 16 in.clear();mp.clear(); 17 dis.clear();pis.clear(); 18 coun=1; 19 string str1,str2; 20 for(int i=1; i<=n; i++) 21 { 22 cin>>str1>>str2; 23 if(pis[str1]==0) 24 { 25 pis[str1]=1; 26 dis[coun++]=str1; 27 } 28 if(pis[str2]==0) 29 { 30 pis[str2]=1; 31 dis[coun++]=str2; 32 } 33 if(mp[str1][str2]==0) 34 { 35 mp[str1][str2]=1; 36 in[str2]++; 37 } 38 } 39 int flag=0; 40 for(int i=1;i<coun;i++) 41 { 42 if(in[dis[i]]==0) 43 { 44 flag++; 45 q.push(dis[i]); 46 } 47 } 48 if(flag==1) 49 printf("Yes\n"); 50 else 51 printf("No\n"); 52 } 53 return 0; 54 }
标签:
原文地址:http://www.cnblogs.com/hsd-/p/4899447.html