您的位置:首页 > 其它

HDU 2094 产生冠军

2016-03-19 10:34 387 查看
题目链接:

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