Logo
(追記) (追記ここまで)

11217번 - Spock 다국어인터랙티브

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB266623.077%

문제

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.

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.

입력

출력

제한

인터랙션

This problem is interactive, proceeding in the rounds of the game. Before the game starts, there will be one line of input containing an integer 100ドル \le r \le 1000,ドル the number of rounds to play.

Then, for each round, your program should write one line containing one of the five strings "rock", "paper", "scissors", "lizard", or "Spock", indicating the option Leo should choose for the next round. After writing this line you need to make sure to flush standard output. Then, one line of input will be available, containing the name of the option chosen by Leo's computer in the round, and the game proceeds to the next round.

예제 입력 1

500
scissors
paper
scissors
rock
scissors
paper
Spock
scissors
rock
scissors
...

예제 출력 1

Spock
Spock
Spock
Spock
Spock
Spock
Spock
Spock
Spock
Spock
...

Suppose that Leo's computer uses the parameters $a = 17,ドル $b = 23,ドル and is initially in state $x = 42$. Then in the first round, the state is updated to $(17 \cdot 42 + 23) \bmod 127 = 102,ドル and since 102ドル \bmod 5 = 2,ドル the first move made by the computer is scissors. In the next round, the state is updated to $(17 \cdot 102 + 23) \bmod 127 = 106,ドル resulting in the move paper. The first 10ドル$ rounds of the game are shown below. In this example, Leo has opted to simply make the move Spock in every single round, which seems to have been a surprisingly good choice -- of these 10ドル$ rounds Leo actually wins 7ドル$ (all but the second, sixth, and seventh) -- but Leo still is not winning 80ドル\%$ of the rounds. In general, this strategy will be too naive to defeat the computer.

The extra newlines in this example are for clarity only, to demonstrate the order of events. You should print exactly one newline character after each move, and the input contains no blank lines either.

힌트

출처

Contest > KTH Challenge > KTH Challenge 2015 F번

  • 문제를 만든 사람: Per Austrin

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /