-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path5544.cpp
83 lines (76 loc) · 1.45 KB
/
5544.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// 5544. 리그
// 2019.12.16
// 정렬
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
struct team
{
int index;
int score;
int rank;
};
bool compare(team& a, team& b)
{
return a.score > b.score;
}
bool compare2(team& a, team& b)
{
return a.index < b.index;
}
vector<team> teams;
int main()
{
int n;
cin >> n;
for (int i = 0; i < n; i++)
{
team tmp;
tmp.index = i + 1;
tmp.score = 0;
tmp.rank = 0;
teams.push_back(tmp);
}
for (int i = 0; i < (n*(n - 1) / 2); i++)
{
int a, b, c, d;
cin >> a >> b >> c >> d;
if (c > d)
{
teams[a - 1].score += 3;
}
else if (c < d)
{
teams[b - 1].score += 3;
}
else
{
teams[a - 1].score += 1;
teams[b - 1].score += 1;
}
}
sort(teams.begin(), teams.end(), compare);
int cnt = 1;
teams[0].rank = cnt;
for (int i = 1; i < n; i++)
{
if (teams[i].score == teams[i - 1].score)
{
teams[i].rank = teams[i - 1].rank;
cnt++;
}
else
{
cnt++;
teams[i].rank = cnt;
}
//cout << teams[i].index << " " << teams[i].score << endl;
}
sort(teams.begin(), teams.end(), compare2);
for (int i = 0; i < n; i++)
{
cout << teams[i].rank << "\n";
}
return 0;
}