标签: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;
}
标签:stl
原文地址:http://blog.csdn.net/shengweisong/article/details/44982121