-
Notifications
You must be signed in to change notification settings - Fork 0
/
1025.cpp
66 lines (56 loc) · 1.16 KB
/
1025.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
#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;
struct testee{
char id[15];
int score;
int final_rank;
int loca_num;
int local_rank;
};
bool cmp(testee a,testee b){
if(a.score != b.score){
return a.score > b.score;
}else{
return strcmp(a.id, b.id) < 0;
}
}
int main(){
testee test[30010];
int N, K, n =0;
scanf("%d", &N);
for(int i = 0; i < N; i++){
scanf("%d", &K);
for(int j = 0; j < K; j++){
scanf("%s %d", test[n + j].id, &test[n + j].score);
test[n + j].loca_num = i+1;
}
//Sorting
sort(test+n, test+n+K, cmp);
//Ranking
test[n].local_rank = 1;
for(int j = 1; j< K; j++){
if(test[n+j].score == test[n+j-1].score){
test[n+j].local_rank = test[n+j-1].local_rank;
}else{
test[n+j].local_rank = j+1;
}
}
n += K;
}
sort(test, test + n, cmp);
test[0].final_rank = 1;
for(int i = 1; i < n; i++){
if(test[i].score == test[i-1].score){
test[i].final_rank = test[i-1].final_rank;
}else{
test[i].final_rank = i+1;
}
}
printf("%d\n", n);
for(int i=0; i < n; i++){
printf("%s %d %d %d\n", test[i].id, test[i].final_rank, test[i].loca_num, test[i].local_rank);
}
return 0;
}