-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUVA-13293.cpp
More file actions
70 lines (55 loc) · 1.15 KB
/
UVA-13293.cpp
File metadata and controls
70 lines (55 loc) · 1.15 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
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<string, int> jogador;
string diminui(string a) {
for (int i = 0; i < a.length(); i++)
a[i] = tolower(a[i]);
return a;
}
bool compStr(string a, string b){
return diminui(a) < diminui(b);
}
bool comp(jogador a, jogador b){
if(a.second != b.second){
return a.second > b.second;
}
return compStr(a.first, b.first);
}
int main()
{
char nome[21];
char c;
int temp, p, pontos = 0;
int caso = 1;
vector<jogador> jogadores;
while(cin >> p){
cout << "Case " << caso << ":" << endl;
caso++;
for(int i = 0; i < p; i++){
jogador novo;
pontos = 0;
scanf(" %[^;]", nome);
cin >> c;
for(int j = 0; j < 5; j++){
for(int k = 0; k < 5; k++){
cin >> temp;
if(temp == 1){
if(k == 4) pontos += 2;
else pontos += 1;
}
}
if(j < 4) cin >> c;
}
novo.first = nome;
novo.second = pontos;
jogadores.push_back(novo);
}
sort(jogadores.begin(), jogadores.end(), comp);
for(int i = 0; i < p; i++){
cout << jogadores[i].first << " " << jogadores[i].second << endl;
}
jogadores.clear();
}
return 0;
}