-
Notifications
You must be signed in to change notification settings - Fork 814
/
Copy path1075. PAT Judge (25) .cpp
67 lines (66 loc) · 1.88 KB
/
1075. PAT Judge (25) .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
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct node {
int rank, id, total = 0;
vector<int> score;
int passnum = 0;
bool isshown = false;
};
bool cmp1(node a, node b) {
if(a.total != b.total)
return a.total > b.total;
else if(a.passnum != b.passnum)
return a.passnum > b.passnum;
else
return a.id < b.id;
}
int main() {
int n, k, m, id, num, score;
scanf("%d %d %d", &n, &k, &m);
vector<node> v(n + 1);
for(int i = 1; i <= n; i++)
v[i].score.resize(k + 1, -1);
vector<int> full(k + 1);
for(int i = 1; i <= k; i++)
scanf("%d", &full[i]);
for(int i = 0; i < m; i++) {
scanf("%d %d %d", &id, &num, &score);
v[id].id = id;
v[id].score[num] = max(v[id].score[num], score);
if(score != -1)
v[id].isshown = true;
else if(v[id].score[num] == -1)
v[id].score[num] = -2;
}
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= k; j++) {
if(v[i].score[j] != -1 && v[i].score[j] != -2)
v[i].total += v[i].score[j];
if(v[i].score[j] == full[j])
v[i].passnum++;
}
}
sort(v.begin() + 1, v.end(), cmp1);
for(int i = 1; i <= n; i++) {
v[i].rank = i;
if(i != 1 && v[i].total == v[i - 1].total)
v[i].rank = v[i - 1].rank;
}
for(int i = 1; i <= n; i++) {
if(v[i].isshown == true) {
printf("%d %05d %d", v[i].rank, v[i].id, v[i].total);
for(int j = 1; j <= k; j++) {
if(v[i].score[j] != -1 && v[i].score[j] != -2)
printf(" %d", v[i].score[j]);
else if(v[i].score[j] == -1)
printf(" -");
else
printf(" 0");
}
printf("\n");
}
}
return 0;
}