100 atcoder#ABC222C. [ABC222C] Swiss-System Tournament
[ABC222C] Swiss-System Tournament
Score : points
Problem Statement
players, with ID numbers through , will participate in a rock-scissors-paper contest.
The contest has rounds. Each round has one-on-one matches, where each player plays in one of them.
For each , the players' ranks at the end of the -th round are determined as follows.
- A player with more wins in the first rounds ranks higher.
- Ties are broken by ID numbers: a player with a smaller ID number ranks higher.
Additionally, for each , the matches in the -th round are arranged as follows.
- For each , a match is played between the players who rank -th and -th at the end of the -th round.
In each match, the two players play a hand just once, resulting in one player's win and the other's loss, or a draw.
Takahashi, who can foresee the future, knows that Player will play in their match in the -th round, where is G
, C
, or P
.
Here, G
stands for rock, C
stands for scissors, and P
stands for paper. (These derive from Japanese.)
Find the players' ranks at the end of the -th round.
Rules of rock-scissors-paper
The result of a rock-scissors-paper match is determined as follows, based on the hands played by the two players.
- If one player plays rock (G) and the other plays scissors (C), the player playing rock (G) wins.
- If one player plays scissors (C) and the other plays paper (P), the player playing scissors (C) wins.
- If one player plays paper (P) and the other plays rock (G), the player playing paper (P) wins.
- If the players play the same hand, the match is drawn.
Constraints
- is
G
,C
, orP
.
Input
Input is given from Standard Input in the following format:
Output
Print lines.
The -th line should contain the ID number of the player who ranks -th at the end of the -th round.
2 3
GCP
PPP
CCC
PPC
3
1
2
4
In the first round, matches are played between Players and , and between Players and . Player wins the former, and Player wins the latter. In the second round, matches are played between Players and , and between Players and . Player wins the former, and Player wins the latter. In the third round, matches are played between Players and , and between Players and . Player wins the former, and Player wins the latter. Therefore, in the end, the players are ranked in the following order: , from highest to lowest.
2 2
GC
PG
CG
PP
1
2
3
4
In the first round, matches are played between Players and , and between Players and . Player wins the former, and Player wins the latter. In the second round, matches are played between Players and , and between Players and . The former is drawn, and Player wins the latter. Therefore, in the end, the players are ranked in the following order: , from highest to lowest.