-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathA1028.cpp
More file actions
35 lines (31 loc) · 720 Bytes
/
A1028.cpp
File metadata and controls
35 lines (31 loc) · 720 Bytes
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
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
struct Student{
int id, score;
char name[12];
} stu[100010];
int N, C;
bool cmp(const Student &s1, const Student &s2){
if(C == 1){
return s1.id < s2.id;
}else if(C == 2){
if(strcmp(s1.name, s2.name) != 0) return strcmp(s1.name, s2.name) < 0;
else return s1.id < s2.id;
}else{
if(s1.score != s2.score) return s1.score < s2.score;
else return s1.id < s2.id;
}
}
int main(){
scanf("%d%d", &N, &C);
for(int i = 0; i < N; ++i){
scanf("%d%s%d", &stu[i].id, stu[i].name, &stu[i].score);
}
sort(stu, stu + N, cmp);
for(int i = 0; i < N; ++i){
printf("%06d %s %d\n", stu[i].id, stu[i].name, stu[i].score);
}
return 0;
}