[BOJ 11217] Spock

View as PDF

Submit solution

Points: 5
Time limit: 1.0s
Memory limit: 256M

Problem types
Allowed languages
Assembly, Awk, C, C++, Java, Pascal, Perl, Python, Sed, Text

Leo is participating in a friendly game of rock-paper-scissors-lizard-Spock against his computer.  The game proceeds in rounds.  In each round, Leo and his computer both choose, simultaneously, between five options: rock, paper, scissors, lizard, and Spock.  Each of these five options wins over two of the other options, as illustrated by Figure F.1.  For example, rock wins over lizard and scissors, but loses against paper and Spock. If both players choose the same option, the round is a draw. In the end, each of the two players gets a score which is the number of rounds they won.</p>

Figure F.1: The mechanics of the game. Illustration by VidTheKid via Wikimedia Commons

Alas, Leo's computer is not the sharpest tool in the shed, and simply follows a strategy where in each round it selects one of the five options uniformly at random.  This makes the game quite boring, because regardless of Leo's strategy, each player is expected to win $40\%$ of the rounds (and $20\%$ of the rounds are expected to be draws).

Did we mention that Leo's computer is a bit lacking in mental capacities already?  Well, it gets worse: in order to pick random options, Leo's computer uses a very simple linear congruential generator (LCG).  The LCG has three parameters: a known prime number $p = 127$, and two fixed but unknown integers $0 \le a < p$ and $0 \le b < p$.  Additionally, it has a state, an integer $0 \le x < p$. To generate a random option, Leo's computer first updates the state according to the rule [x \leftarrow (a \cdot x + b) \bmod p,] and then chooses one of the five options based on the value of $x \bmod 5$, according to the following table:

$x \bmod 5$ $0$ $1$ $2$ $3$ $4$
Option chosen: rock paper scissors lizard Spock

Logically, knowing how Leo's computer chooses its random numbers should give Leo an advantage in the game.  But unfortunately Leo died, so it is now up to you to finish this.  Write a program which, when playing against Leo's computer for several rounds, wins at least $80\%$ of them.

입력 형식

출력 형식

예제 입력

500

scissors

paper

scissors

rock

scissors

paper

Spock

scissors

rock

scissors

...

예제 출력

Spock

Spock

Spock

Spock

Spock

Spock

Spock

Spock

Spock

Spock

...

Comments

There are no comments at the moment.