-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA1025.cpp
More file actions
58 lines (53 loc) · 1.31 KB
/
A1025.cpp
File metadata and controls
58 lines (53 loc) · 1.31 KB
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
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
//#include <cmath>
using namespace std;
struct one{
int grade,rank,rank0,loc;
string num;
};
bool cmp(one a,one b){
if (a.grade!=b.grade) return a.grade>b.grade;
else return a.num<b.num;
}
int main() {
int n,sum=0;
cin>>n;
int *k=new int[n];
vector<one> *a=new vector<one>[n];
vector<one> b;
one p;
for (int i=0; i<n; i++) {
cin>>k[i];
sum+=k[i];
for (int j=0; j<k[i]; j++) {
cin>>p.num>>p.grade;
p.loc=i+1;
a[i].push_back(p);
}
sort(a[i].begin(),a[i].end(),cmp);
for (int j=0; j<k[i]; j++) {
if (j==0) a[i][0].rank=1;
else{
if (a[i][j].grade==a[i][j-1].grade) a[i][j].rank=a[i][j-1].rank;
else a[i][j].rank=j+1;
}
}
b.insert(b.end(),a[i].begin(),a[i].end());
}
sort(b.begin(),b.end(),cmp);
cout<<sum<<endl;
for (int i=0; i<sum; i++) {
if (i==0) b[0].rank0=1;
else{
if (b[i].grade==b[i-1].grade) b[i].rank0=b[i-1].rank0;
else b[i].rank0=i+1;
}
cout<<b[i].num<<" "<<b[i].rank0<<" "<<b[i].loc<<" "<<b[i].rank<<endl;
}
delete []k;
delete []a;
return 0;
}