Sicily 1027. MJ, Nowhere to Hide

来源:互联网 发布:tensorflow mnist教程 编辑:程序博客网 时间:2024/05/17 06:00
#include <iostream>#include <string>#include <map>using namespace std;struct BBS {string name;string ip;};int main(){int n;BBS bbs[20];while (cin >> n && n) {map<string, string> user;map<string, string> account;for (int i = 0; i < n; i++) {cin >> bbs[i].name >> bbs[i].ip;}int cnt;map<string, string>::iterator it;for (int i = 0; i < n; i++) {cnt = account.count(bbs[i].ip);if (cnt == 0) {account.insert(pair<string, string>(bbs[i].ip, bbs[i].name));} else {it = account.find(bbs[i].ip);user.insert(pair<string, string>(it->second, bbs[i].name));}}for (it = user.begin(); it != user.end(); it++) {cout << it->second << " is the MaJia of " << it->first << endl;}cout << endl;}return 0;}                                 


                                             
0 0
原创粉丝点击