[HDU] 2094 产生冠军(拓扑排序+map)
2024-10-13 16:44:39
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2094
注意每组数据处理前,map要清空。
#include<cstdio>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<stdbool.h>
#include<time.h>
#include<stdlib.h>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<vector>
using namespace std;
#define clr(x,y) memset(x,y,sizeof(x))
#define sqr(x) ((x)*(x))
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define LL long long
#define INF 0x3f3f3f3f
#define A first
#define B second
const int N=+;
int n,cnt,num,t,head[N],f[N],d[N];
char a[N],b[N];
map<string,int> all; void init()
{
num=;
clr(d,);
all.clear();
}
void solve()
{
int p=;
for(int i=;i<=num;i++) {
if(!d[i]) p++;
}
if(p!=) printf("No\n");
else printf("Yes\n"); }
int main()
{
while(~scanf("%d",&n)) {
if(!n) break;
getchar();
init();
while(n--) {
scanf("%s%s",a,b);
if(!all[a]) all[a]=++num;
if(!all[b]) all[b]=++num;
d[all[b]]++;
}
solve();
} return ;
}
最新文章
- 帆布指纹识别(canvas fingerprinting)
- Linux下Tomcat服务器重启与关闭
- [转载] Android Bander设计与实现 - 设计篇
- discuz!安装遇到问题的解决方案
- 统计:P值 &; α值
- swift流行UI库(github)
- Velocity语法大全
- JAVA &; Android 系统环境变量配置
- (C++)STL排序函数sort和qsort的用法与区别
- N皇后摆放问题
- Nested Loop,Sort Merge Join,Hash Join
- Eclipse 中使用Genymotion 作为模拟器的步骤
- AngularJS中ng-options简单用法及预选项失败的原因
- ios 检测屏幕方向
- 学习java线程学习笔记
- django ajax练习
- CodePen最佳实例分享
- 2013-8:SDCE大会笔记
- Filebeat 模块与配置
- UI设计教程分享:字体变形—阴阳收缩法