hdu 2094 产生冠军
2010-09-06 09:30
507 查看
问题描述:
给N个比赛的结果,求能不能产生冠军
解决方法:
只有当都没有输过一场比赛的人数为1时,就能产生冠军,否则不能。
代码如下:
给N个比赛的结果,求能不能产生冠军
解决方法:
只有当都没有输过一场比赛的人数为1时,就能产生冠军,否则不能。
代码如下:
/* Author: ACb0y Date: 2010年9月6日9:21:47 Type: Water() ProblemId:hdu 2094 产生冠军 Result: 2923032 2010-09-06 09:20:14 Accepted 2094 31MS 276K 643 B C++ ACb0y */ #include <iostream> #include <string> #include <map> using namespace std; int main() { int n; #ifndef ONLINE_JUDGE freopen("2094.txt", "r", stdin); #endif while (cin >> n) { if (n == 0) { break; } string a, b; map<string, int> m; for (int i = 0; i < n; i++) { cin >> a >> b; if (m.find(a) == m.end()) { m[a] = 0; } if (m.find(b) == m.end()) { m[b] = -1; } else { m[b]--; } } int c = 0; map<string, int>::iterator it; for (it = m.begin(); it != m.end(); it++) { if (it->second == 0) { c++; } } if (c == 1) { cout << "Yes" << endl; } else { cout << "No" << endl; } } return 0; }
相关文章推荐
- Hdu 2094 产生冠军 程序参考
- 产生冠军 HDU杭电 2094【字符串处理】
- hdu 2094 产生冠军(水题)
- hdu2094——产生冠军
- HDU 2094 产生冠军 (字典树+拓扑)
- HDU 2094 产生冠军
- hdu 2094 产生冠军
- HDU 2094 产生冠军(STL 集合set)
- HDU 2094 产生冠军 解题报告
- HDU 2094 产生冠军
- HDU 2094 产生冠军
- hdu-2094 产生冠军
- ACM 算法总结 --- 排序 HDOJ HDU 2094 产生冠军 ACM 2094 IN HDU
- hdu 2094 产生冠军 寒假集训1 09
- HDU 2094 产生冠军
- [HDU] 2094 产生冠军(拓扑排序+map)
- HDU 杭电 acm 2094-产生冠军
- 刷题篇--HDU 2094 产生冠军(水拓扑)
- HDU 2094(产生冠军)
- 产生冠军 HDU - 2094