HDU 2094 产生冠军
2016-03-19 10:34
387 查看
题目链接:
HDU 2094 产生冠军
分析:
只需要判断是否有且仅有一个人没被打败即可。
HDU 2094 产生冠军
分析:
只需要判断是否有且仅有一个人没被打败即可。
//1637K 93MS #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <map> using namespace std; const int maxn=1010; int n,tot,a,b; int vis[maxn*2]; map<string,int> mp; map<string,int>:: iterator it; string s1,s2; int main() { //freopen("hdu2094in.txt","r",stdin); while(~scanf("%d",&n)&&n){ memset(vis,0,sizeof(vis)); tot=0; mp.clear(); for(int i=0;i<n;i++){ cin>>s1>>s2; if((it=mp.find(s1))!=mp.end()){ a=it->second; }else{ mp[s1]=tot++; a=tot-1; } if((it=mp.find(s2))!=mp.end()){ b=it->second; }else{ mp[s2]=tot++; b=tot-1; } vis[b]=1; } int cnt=0; for(int i=0;i<tot;i++){ if(vis[i]==0) cnt++; if(cnt>=2) break; } if(cnt==1) printf("Yes\n"); else printf("No\n"); } return 0; }
相关文章推荐
- 【HDU 5366】The mook jong 详解
- 【HDU 2136】Largest prime factor 详细图解
- 【HDU 1568】Fibonacci 数学公式 详解
- HDU 1568
- HDU1290
- HDU1568(Fobonacci公式)
- HDU ACM Step 2.2.2 Joseph(约瑟夫环问题)
- HDU 1405
- HDU 1297
- hdu 1205
- hdu 2087
- hdu 1016
- HDU 4898 The Revenge of the Princess’ Knight ( 2014 Multi-University Training Contest 4 )
- HDU 5592 ZYB's Premutation 线段树(查找动态区间第K大)
- HDU 5240 Exam (好水的题)
- HDU5237 Base64 大模拟
- HDU 1000
- HDU 1001
- 2015-11-11 hdu新生赛 A题(AC)
- 2015-11-11 hdu新生赛 C题(结束后一发AC)