This is an interactive problem.
If you know the rule of the game Rock-Paper-Scissors, then you can skip the next paragraph.
RockPaperScissors or Scissor-Paper-Rock, is a zero-sum hand game usually played between two
people, in which each player simultaneously forms one of three shapes with an outstretched hand.
These shapes are "rock"(a simple fist), "paper"(a flat hand), and "scissors"(a fist with the index
and middle fingers together forming a V). The game has only two possible outcomes other than
a tie: a player who decides to play rock will beat another player who has chosen scissors ("rock
crushes scissors") but will lose to one who has played paper ("paper covers rock"); a play of paper
will lose to a play of scissors ("scissors cut paper"). If both players choose the same shape, the
game is tied and is usually immediately replayed to break the tie. Other names for the game in
the English-speaking world include roshambo and other orderings of the three items, sometimes
with "rock"being called "stone".
GSS, who loves playing RPS, is going to attend a contest of RPS, however, his opponent is a
computer. Just at the day before the contest, GSS found a bug of the contest server and get the
code of computer.
However, the code is written in LISP. So he translated the code into pseudo code.
def rps(int your_shape)
global last_random
if this is the first call of this function:
last_random
computer_shape
last_random
computer_shape
result
if result is 2: return -1
elif result is 1: return 1
elif result is 0: return 0
After the translation, GSS is tired and ask you to help him. He said that your goal is to win 1000
rounds continously in no more than 2000 rounds.
More exactly, your task is to let the function continously return 1 for 1000 times in no more than
2000 calls.
And for different languages, you have to do the following things:
Common notes For all languages you can use, we will provide a head file / class / package
which comtians a function.
The function will return one of {0,1,−1,100}
If the function returns 0, then there is a tie, if the function returns -1, then you lose, if the function
returns 1, then you win.
If the function returns 100, you should end your program.
Do not read anything from stdin or output anything to stdout, or the behavior is undefined.
C / C++ If you are using C or C++, you have to include rps.h.
That head provides a function int cc17_rps(int your_shape).
Then, you can call cc17_rps(your_shape) to play the game with computer.
For example, if your shape is Paper then you should call cc17_rps(0), Scissors call cc17_rps(1)
and Rock call cc17_rps(2).
Java If you are using Java, we will provide a class named CC17.
Firstly, you have to write CC17 rps = new CC17(System.in, System.out);. Then you will get
an object called rps. Please note that you can only do this once or the behavior is undefined.
That class provides a function public int rps(int yourShape).
Then, you can call rps.rps(yourShape) to play the game with computer.
For example, if your shape is Paper then you should call rps.rps(0), Scissors call rps.rps(1)
and Rock call rps.rps(2).
Python2 / 3 If you are using Python, we will provide a package named CC17, you should import
CC17 in your source code.
That package provides a function rps(your_shape).
Then, you can call CC17.rps(your_shape) to play the game with computer.
For example, if your shape is Paper then you should call CC17.rps(0), Scissors call CC17.rps(1)
and Rock call CC17.rps(2).