forked from ksaveljev/UVa-online-judge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10258.cpp
104 lines (81 loc) · 2.35 KB
/
10258.cpp
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct submit{
int problem;
int time;
char result;
};
struct team {
int id;
int solved;
int time;
bool submission_made;
team() : solved(0), time(0), submission_made(false) {}
};
bool theTruthIsOutThere(const team &a, const team &b) {
if (a.solved == b.solved) {
if (a.time == b.time) {
if (a.submission_made == b.submission_made) {
return a.id < b.id;
}
return a.submission_made;
}
return a.time < b.time;
}
return a.solved > b.solved;
}
int main(void) {
int cases;
int contestant;
submit tmp;
bool solved_already;
cin >> cases;
cin.ignore(100, '\n');
cin.ignore(100, '\n');
while (cases--) {
team teams[101];
vector<submit> contestants[101];
for (int i = 0; i < 101; i++)
teams[i].id = i;
while (cin.peek() != '\n' && cin.peek() != -1) {
cin >> contestant >> tmp.problem >> tmp.time >> tmp.result;
//cout << contestant << " " << tmp.problem << " " << tmp.time << " " << tmp.result << endl;
cin.ignore(100, '\n');
teams[contestant].submission_made = true;
if (tmp.result == 'C') {
solved_already = false;
for (int i = 0, sz = contestants[contestant].size(); i < sz; i++) {
if (contestants[contestant][i].problem == tmp.problem && contestants[contestant][i].result == 'C') {
solved_already = true;
break;
}
}
if (!solved_already) {
teams[contestant].time += tmp.time;
teams[contestant].solved += 1;
for (int i = 0, sz = contestants[contestant].size(); i < sz; i++) {
if (contestants[contestant][i].problem == tmp.problem && contestants[contestant][i].result == 'I') {
teams[contestant].time += 20;
}
}
}
}
contestants[contestant].push_back(tmp);
}
cin.ignore(100, '\n');
sort(teams, teams + 101, theTruthIsOutThere);
//for (int i = 0; i < 101; i++) {
// cout << teams[i].id << " " << teams[i].solved << " " << teams[i].time << endl;
//}
for (int i = 0; i < 101; i++) {
if (teams[i].submission_made == false)
break;
cout << teams[i].id << " " << teams[i].solved << " " << teams[i].time << endl;
}
if (cases)
cout << endl;
}
return 0;
}