首页 > 其他 > 详细

hdoj 2094 产生冠军 【拓扑】+【STL】

时间:2015-04-10 17:53:20      阅读:81      评论:0      收藏:0      [点我收藏+]

题意。。。
今天学了map和set赶紧练练手。
统计一下一共有多少人,被打败的有多少人,用总数减去被打败的人数,如果为一那么就有冠军,否则没有。。
好水啊,就是两个set
代码:

#include <iostream>
#include <string>
#include <map>
#include <set>
using namespace std;

int main(){
    int n;
    //multimap<string, string> m;
    set<string > s, temp;
    while(cin >> n, n){
        m.clear(); s.clear();
        temp.clear();
        string a, b;
        for(int i = 0; i < n; ++ i){
            cin >> a >> b;
        //  m.insert(pair<string, string>(a, b));
            s.insert(a); s.insert(b); temp.insert(b);
        }
        //multimap<string, string>::iterator it = m.begin();
        if(s.size() - temp.size() == 1){
            cout << "Yes\n";
        }
        else cout << "No\n";
    } 
    return 0;
}

hdoj 2094 产生冠军 【拓扑】+【STL】

原文:http://blog.csdn.net/shengweisong/article/details/44982121

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!