-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2018.cpp
More file actions
74 lines (66 loc) · 1.64 KB
/
2018.cpp
File metadata and controls
74 lines (66 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <bits/stdc++.h>
using namespace std;
struct medalhas{
int a, b, c;
};
bool compara(pair<string, medalhas> a, pair<string, medalhas> b){
if(a.second.a == b.second.a)
if(a.second.b == b.second.b)
if(a.second.c == b.second.c)
return a.first < b.first;
else
return a.second.c > b.second.c;
else
return a.second.b > b.second.b;
else
return a.second.a > b.second.a;
}
int main(){
string s;
map<string, medalhas> m;
while(getline(cin, s)){
getline(cin, s);
if(m.find(s) == m.end()){
medalhas aux;
aux.a = 1;
aux.b = 0;
aux.c = 0;
m[s] = aux;
}
else{
m[s].a++;
}
getline(cin, s);
if(m.find(s) == m.end()){
medalhas aux;
aux.a = 0;
aux.b = 1;
aux.c = 0;
m[s] = aux;
}
else{
m[s].b++;
}
getline(cin, s);
if(m.find(s) == m.end()){
medalhas aux;
aux.a = 0;
aux.b = 0;
aux.c = 1;
m[s] = aux;
}
else{
m[s].c++;
}
}
//sort(m.begin(), m.end());
vector<pair<string, medalhas>> v;
for(auto it = m.begin(); it != m.end(); it++){
v.push_back(make_pair(it->first, it->second));
}
sort(v.begin(), v.end(), compara);
cout<<"Quadro de Medalhas"<<endl;
for(auto it = v.begin(); it != v.end(); it++){
cout<<it->first<<" "<<it->second.a<<" "<<it->second.b<<" "<<it->second.c<<endl;
}
}