Rock-Paper-Scissors (APCS 2020-01 Beginner)

Points 100 1.0s 256M

Little Sisi loves playing rock-paper-scissors with her older brother, since it is one of the few games she has a chance of winning. Every day after coming home she asks her brother to play. To beat him, she spends a lot of time at kindergarten working out a strategy and writes down the throws she plans to make. But now that the brother is in junior high with more and more homework, he has no time to plan his throws in advance, so he decides each throw based on Sisi's throws.

Each day the brother only decides his first throw \(F\); after that his strategy is:

  • If Sisi played the same throw in the previous two rounds, his next throw is the one that beats Sisi's throw in those two rounds.
  • Otherwise, his next throw is the same as Sisi's previous throw.

Throws are denoted \(0\), \(2\), \(5\) for rock, scissors, paper. The rules are: rock (\(0\)) beats scissors (\(2\)), scissors (\(2\)) beats paper (\(5\)), paper (\(5\)) beats rock (\(0\)); two equal throws are a tie.

Write a program that simulates the game and its result.

Input

The first line contains the brother's first throw \(F\).

The second line contains the count \(N\) of Sisi's throws.

The third line contains Sisi's throws \(y_1, y_2, \ldots, y_N\) in order, separated by spaces.

Constraints

  • Every throw is \(0\), \(2\), or \(5\) (\(0\) rock, \(2\) scissors, \(5\) paper)
  • \(1 \le N \le 10\)

Output

Output a single line: the brother's throw for each round in order, separated by spaces, followed by a colon stating the round in which the game is decided:

  • If the brother wins in round \(k\), output : Won at round k
  • If the brother loses in round \(k\), output : Lost at round k
  • If it is still a tie after all \(N\) rounds, output : Drew at round N

Scoring

The time limit for each test case is \(1\) second; your score is the sum over the test cases you pass. The subtasks are:

  • Subtask 1 (\(20\) points): \(N = 1\).
  • Subtask 2 (\(20\) points): \(N = 2\) and \(y_1 \ne y_2\).
  • Subtask 3 (\(60\) points): no additional constraints.

Sample Input 1

0
4
2 5 0 2

Sample Output 1

0 : Won at round 1

Sample Input 2

2
2
2 0

Sample Output 2

2 2 : Lost at round 2

Sample Input 3

5
4
5 5 0 0

Sample Output 3

5 5 2 : Lost at round 3

Sample Input 4

5
6
5 5 2 2 0 0

Sample Output 4

5 5 2 2 0 0 : Drew at round 6

Source

APCS programming exam, January 2020, Problem 1.

Problem page help

Keyboard shortcuts

Main features

  • Sample tests — Runs the sample cases bundled with the problem and auto-compares against the expected output.
  • Custom test — Run your code with your own stdin. Optionally tick the "Compare with expected (diff)" box to verify against expected output line-by-line.
  • Template — Paste the default code template you set on your profile page.
  • Collab — Edit this problem together with classmates in real time.
  • Auto-draft — Editor contents auto-save to your browser every 1.5 seconds (per account / problem / language).
  • Submit — Send your code to the judge for grading; returns AC / WA / TLE etc.

Limits

  • Source code: at most 65,536 characters
  • Custom test stdin and expected output: at most 1 MB each (≈1 million characters)
  • Custom test and sample test share the sandbox; about 1 request per 3 s per user (sample test: 1 per 1 s)
  • Custom test and sample test both have a 15 second wall-clock cap (the official judge still uses the problem time limit)
  • Interactive problems do not offer custom test (cannot simulate interaction with the judge).
  • Submitting has no rate limit, but rapid repeated submissions on the same problem are treated as score farming.