-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPAT_Ranking.cpp
63 lines (61 loc) · 1.48 KB
/
PAT_Ranking.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
#include <algorithm>
#include <iostream>
#include <string>
struct textee
{
std::string name;
int scroe;
int finrank, localnum, localrank;
};
textee text[30010];
bool cmp(textee a, textee b)
{
if (a.scroe == b.scroe)
return a.name < b.name;
return a.scroe > b.scroe;
}
int main()
{
std::ios::sync_with_stdio(false);
int n;
std::cin >> n;
int p = 0;
for (int i = 0; i < n; i++)
{
int temp;
std::cin >> temp;
for (int j = p; j < p + temp; j++)
{
std::cin >> text[j].name >> text[j].scroe;
text[j].localnum = i + 1;
}
std::sort(text + p, text + p + temp, cmp);
text[p].localrank = 1;
for (int j = p + 1; j < p + temp; j++)
{
if (text[j].scroe == text[j - 1].scroe)
text[j].localrank = text[j - 1].localrank;
else
text[j].localrank = j - p + 1;
}
p = p + temp;
}
std::sort(text, text + p, cmp);
text[0].finrank = 1;
for (int i = 1; i < p; i++)
{
if (text[i].scroe == text[i - 1].scroe)
text[i].finrank = text[i - 1].finrank;
else
text[i].finrank = i + 1;
}
std::cout << p << std::endl;
for (int i = 0; i < p; i++)
{
std::cout << text[i].name << " "
<< text[i].finrank << " "
<< text[i].localnum << " "
<< text[i].localrank << std::endl;
}
return 0;
}