A higher resolution is required to access the IDE
- 117
Statement
Goal
n opponents, all standing in a circle around you (clockwise from playerYou have to win as many of the games as you can, by playing a single move (either
- You may start with any opponent, but you must win the first game.
- After the first win, play the same move against each following opponent in the circle, until you lose a game, or until you have played every opponent.
- A draw does not count as a win, or as a loss.
- If there is more than one possible play with the maximum number of wins, the play starting from the lower-numbered opponent takes priority.
For anyone who never played the game:
https://en.wikipedia.org/wiki/Rock_paper_scissors
EXAMPLE
6
Scissors
Paper
Rock
Paper
Scissors
Rock
The players surround you, and declare their moves:
0=S
5=R 1=P
YOU
4=S 2=R
3=P
Starting at
Starting at
Starting at
Starting at
Starting at
Starting at
Solution:
Rock
4
Input
First line: integer n, the number of opponents
Next n lines: string a, representing each player's move (starting with player0 , and proceeding clockwise around you)
Next n lines: string a, representing each player's move (starting with player
Output
The move that maximises the number of games you win:
First line: Your move b
Second line: Integer p, the 0-indexed position of your starting opponent
First line: Your move b
Second line: Integer p, the 0-indexed position of your starting opponent
Constraints
1 <= n <= 10
a and b may beRock , Paper , or Scissors
a and b may be
Example
Input
4 Paper Paper Paper Rock
Output
Scissors 0
A higher resolution is required to access the IDE