hiho week 213 register

Ended

Participants:178

Verdict:Accepted
Score:100 / 100
Submitted:2018-07-29 09:21:41

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <unordered_map>
#include <string>
#include <iostream>
using namespace std;
int main()
{
    unordered_map<string, int> degree;
    int n(0);
    string a, b;
    cin>>n;
    for(int i=0; i<n; ++i){
        cin>>a>>b;
        degree[a] += 1;
        degree[b] -= 1;
    }
    for(auto it = degree.begin(); it!=degree.end(); it++){
        if(it->second==-1) b = it->first;
        else if(it->second == 1) a = it->first;
    }
    cout<<a<<' '<<b<<endl;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX