-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathuva-10258.cpp
121 lines (91 loc) · 2.57 KB
/
uva-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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
//uva 10258
//Contest Scoreboard
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int contestantNum(string a);
int problemNum(string a);
int timeCount(string a);
int main(void)
{
int T = 0;
cin >> T;
string input;
getline(cin, input);
getline(cin, input);
while (T--){
int penalty[100] = {0};
bool solved [100][10] = {0};
int unsolved[100][10] = {0};
bool submit[100] = {false};
while (true){
getline(cin, input);
if (input == "")
break;
int conNum = contestantNum(input) - 1;
int pNum = problemNum(input) - 1;
int time = timeCount(input);
char status = input[input.size() - 1];
submit[conNum] = true;
if (status == 'C'){
if (!solved[conNum][pNum]){
solved[conNum][pNum] = 1;
penalty[conNum] += time;
}
}
else if (status == 'I')
if (!solved[conNum][pNum]){
++unsolved[conNum][pNum];
}
}
vector < pair<int, pair<int, int> > > board;
for (int i = 0; i < 100; ++i)
for (int j = 0; j < 10; ++j)
if (solved[i][j])
penalty[i] += (20 * unsolved[i][j]);
for (int i = 0; i < 100; ++i){
int count = 0;
for (int j = 0; j < 10; ++j)
if (solved[i][j])
++count;
if (submit[i])
board.push_back(make_pair(count, make_pair(-penalty[i], -(i + 1))));
}
sort(board.begin(), board.end());
for (auto a = board.crbegin(); a != board.crend(); ++a)
cout << -a->second.second << ' ' << a->first << ' ' << -a->second.first << endl;
if (T != 0)
cout << endl;
}
return 0;
}
int contestantNum(string a)
{
int code = 0;
for (int i = 0; i < a.size() && a[i] != ' ' ; ++i)
code = code * 10 + a[i] - '0';
return code;
}
int problemNum(string a)
{
int code = 0;
int i = 0;
for (i = 0; i < a.size() && a[i] != ' '; ++i);
++i;
for (; i < a.size() && a[i] != ' '; ++i)
code = code * 10 + a[i] - '0';
return code;
}
int timeCount(string a)
{
int code = 0;
int i = 0;
for (i = 0; i < a.size() && a[i] != ' '; ++i);
++i;
for (; i < a.size() && a[i] != ' '; ++i);
++i;
for (; i < a.size() && a[i] != ' '; ++i)
code = code * 10 + a[i] - '0';
return code;
}