-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path27B_tournament.cpp
45 lines (38 loc) · 1.03 KB
/
27B_tournament.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
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
int32_t main()
{
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
std::cout.tie(NULL);
int participants_number;
std::cin >> participants_number;
std::vector <int> matches(participants_number + 2, 0);
std::vector <int> wins(participants_number + 2, 0);
std::vector <int> loses(participants_number + 2, 0);
int games_number = participants_number * (participants_number - 1) / 2;
for (int i = 0; i < games_number - 1; ++i)
{
int participant1, participant2;
std::cin >> participant1 >> participant2;
++matches[participant1];
++matches[participant2];
++wins[participant1];
++loses[participant2];
}
std::vector <int> possible;
for (int i = 1; i <= participants_number; ++i)
{
if (matches[i] < participants_number - 1)
{
possible.push_back(i);
if (possible.size() == 2)
{
if (wins[possible[0]] < wins[possible[1]]) std::swap(possible[0], possible[1]);
std::cout << possible[0] << ' ' << possible[1] << '\n';
return 0;
}
}
}
return 0;
}