#P8770. Paper Cutter and Rat Exterminator

    ID: 21934 Type: Default 1000ms 256MiB

Paper Cutter and Rat Exterminator

Paper Cutter and Rat Exterminator

Problem Description

This contest problem consists of two independent subproblems. You are required to output two answers on separate lines:

Subproblem A: Paper Cutter

Blue has a paper cutter that can split a single sheet of paper into two pieces with a single straight cut. Blue printed a sheet containing a 2 x 3 grid of QR codes. Due to the printer inaccuracy (the printer cannot print right to the edge), extra cuts are required on the borders. In the sample case, at least 9 cuts are needed; note that the border must be cut at least 4 times, and each cut can only be made on one piece at a time.

If Blue prints a sheet with a grid of 20 rows and 22 columns (i.e. a total of 440 QR codes), what is the minimum number of cuts required? It can be verified that the answer is calculated by the formula: $$\text{cuts} = (\text{rows}\times\text{columns} - 1) + (\text{rows} + \text{columns} - 1) = \text{rows}\times\text{columns} + \text{rows} + \text{columns} - 2.$$ For 20 rows and 22 columns, the answer is $$20\times22+20+22-2=480.$$

Subproblem B: Rat Exterminator

The game "Rat Exterminator" is played on a 2 x 4 board by two players who take turns. On a turn, a player may:

  • Place a piece on any single empty square, or
  • Place pieces on two adjacent (horizontally contiguous) empty squares in the same row.

However, after a move, if the board becomes completely full, then the player who made that move loses. Blue moves first, and both players play optimally. Four specific initial board configurations (given by the top row of the board, with 'X' indicating an already placed piece and 'O' indicating an empty cell; the bottom row is always completely empty) are considered:

Case 1:
X000
0000

Case 2:
XX00
0000

Case 3:
OXOO
0000

Case 4:
OXXO
0000

For each case, determine whether Blue can force a win. Use 'V' to denote a winning position (Victory) for Blue and 'L' to denote a losing position. Under optimal play, the outcomes for the four cases (in the given order) are:

Case 1: L Case 2: V Case 3: L Case 4: V

Thus the answer string is LVLV.

Answer Submission: This is a result-only problem. Your program should print two lines: the first line is the answer for Subproblem A (an integer) and the second line is the answer for Subproblem B (a 4-character string consisting only of the letters V and L). Do not output any extra characters or spaces.

inputFormat

There is no input for this problem. The answer is completely determined by the problem statement.

outputFormat

The output should consist of exactly two lines:

  • The first line contains an integer, which is the minimum number of cuts required for the Paper Cutter problem.
  • The second line contains a 4-character string (each character is either 'V' or 'L') representing the outcomes for the four cases in the Rat Exterminator problem.

sample

480

LVLV

</p>