-
Notifications
You must be signed in to change notification settings - Fork 0
/
10258.cpp
97 lines (81 loc) · 2.11 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
#include <cstdio>
#include <cstring>
using namespace std;
int corr[101], total[101], score[101][11];
inline int cmp(int x, int y)
{
if (corr[x] != corr[y])
return corr[x] - corr[y];
else if (total[x] != total[y])
return total[y] - total[x];
else
return y - x;
}
void sortL(int *list, int len)
{
int i = 0;
int j = len - 1;
int tmpS, pivot = list[len / 2];
if (len < 2) return;
while (true) {
while (cmp(list[i], pivot) > 0)
++i;
while (cmp(list[j], pivot) < 0)
--j;
if (i >= j) break;
tmpS = list[i];
list[i++] = list[j];
list[j--] = tmpS;
}
sortL(list, i);
sortL(list + i, len - i);
}
int main(void)
{
bool check[101], prob[101][11];
char str[101], stat;
int times, i, j, list[101], lenL, l, n, t;
scanf("%d\n", ×);
while (times--) {
lenL = 0;
for (i = 1; i < 101; ++i) {
check[i] = false;
for (j = 1; j < 11; ++j) {
prob[i][j] = false;
score[i][j] = 0;
}
corr[i] = 0;
total[i] = 0;
}
while (true) {
str[0] = '\0';
gets(str);
if (!strlen(str)) break;
sscanf(str, "%d %d %d %c\n", &l, &n, &t, &stat);
check[l] = true;
if (!prob[l][n]) {
if (stat == 'C') {
prob[l][n] = true;
score[l][n] += t;
}
else if (stat == 'I') {
score[l][n] += 20;
}
}
}
for (i = 1; i < 101; ++i)
if (check[i]) {
list[lenL++] = i;
for (j = 1; j < 11; ++j)
if (prob[i][j]) {
corr[i]++;
total[i] += score[i][j];
}
}
sortL(list, lenL);
for (i = 0; i < lenL; ++i)
printf("%d %d %d\n", list[i], corr[list[i]], total[list[i]]);
if (times) printf("\n");
}
return 0;
}