Mock CCC '22 Contest 2 J4 - Hockey Bracket
View as PDFThe hockey event at the Winter Olympics will be happening soon! UselessLeaf will bet with his friends about how the countries will place.
The tournament will be operating in a round-robin fashion. There are countries competing, numbered from
to
, and they will be split into groups of size
.
matches will then occur in each group, where each country in their group play against each other country in the group once, resulting in a total of
matches. After a match, the winning country gains 3 points, while the losing country gains 0. If it is a tie, both countries gain 1 point.
The tournament ends when all matches have been played. The countries in each group will then be ranked by their points. If there is a tie, the lower-numbered country should be ranked better (for example, if country
and country
where
got the same number of points, country
should be ranked better than country
).
A time traveller has suddenly appeared and provided UselessLeaf with the results of the matches. He provides the two countries in the match,
and
, and the result of the match, an uppercase letter
where
W means country won the match,
L means country won the match, and
T means the match ended in a tie.
UselessLeaf is participating in a bet where he has to guess the country that places in each group and needs your help figuring this out!
Constraints
WLT
Subtask 1 [5/15]
Subtask 2 [10/15]
No additional constraints.
Input Specification
The first line will contain two space-separated integers , the number of countries competing, and
, the number of countries in each group.
The next lines will contain
space-separated integers, the
line containing the countries that are in the
group.
The next lines will contain two space-separated integers
and
, the countries involved in this match, and one character
, the result of the match between country
and country
.
The next line will contain one integer , where UselessLeaf must figure out which country placed
in each group.
Output Specification
Output space-separated integers, the
integer being the country that placed
in the
group.
Sample Input
4 2
3 1
2 4
1 3 W
2 4 T
2
Sample Output
3 4
Explanation
In group , since
1 beat 3, 1 is ranked , while
3 is ranked .
In group
, there is a tie for first and second in terms of points between
2 and 4, but 2 is the lower numbered country so is ranked , meaning
4 is ranked .
Comments
Great Question by a great Author!!
agreed.