码迷,mamicode.com
首页 > 其他好文 > 详细

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

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

标签:stl

题意。。。
今天学了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】

标签:stl

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!