P29787 [洛谷] [BalticOI 2002 Day2] L Game © Edward de Bono
提高+
题目描述

Problem Description

L Game is a two-player board game played on a $4 \times 4$ square board.

There are two types of pieces:
- L-shaped pieces: Each player has one, and they occupy 4 squares.
- Neutral pieces: There are two, occupying 1 square each, and they are neutral.

At any time, no more than one piece can occupy any square on the board.

Players take turns. A valid move consists of moving one's own L-shaped piece to a valid position different from its current position, followed by moving at most one neutral piece.

The player who cannot make a valid move loses.

The player with the L-shaped piece marked with a grid is referred to as A, and the one marked with diagonal lines is B.

If the game is in one of the three situations shown above and A is the first to move, A can only move their L-shaped piece to one of the other two situations. After that, A can move one of the neutral pieces to an empty square or choose not to move any neutral piece. Therefore, A has $2 \times (6 + 6 + 1)$ possible moves.

If the game is in the situation shown below and A is the first to move, A loses because they cannot move their L-shaped piece, and B wins.

A "winning move" is one where the first player has a guaranteed winning strategy after making it. A "losing position" is one where no matter what move the first player makes, the second player has a guaranteed winning strategy. A "draw position" is one where there is no winning move and it is not a losing position.

Despite the small board, there are over $18,000$ possible positions in L Game; and at any given time, the first player may have up to $195$ possible moves, but only one of them is a winning move.

For a given position, find a winning move, or determine if the position is a losing position or a draw position. If there are multiple winning moves, output any one of them.

Input Format

Four lines, each containing four characters, representing the board state.

  • # indicates the position of the first player's piece.
  • * indicates the position of the second player's piece.
  • x indicates the position of a neutral piece.
  • . indicates an empty square.

Output Format

  • If there is a winning move, output the board state after the move, in the same format as the input. Note that # still represents the first player's piece before the move, and * represents the second player's piece before the move.

  • Otherwise, output the string No winning move on the first line.

  • If it is a draw position, output the string Draw on the second line.
  • If it is a losing position, output the string Losing on the second line.

Note: Although the Special Judge ignores trailing carriage returns and line breaks at the end of the file, do not output more than $64$ characters, or it will be judged as Wrong Answer.

Sample Input and Output

Input Sample #1

.*** 
#*.x 
###. 
x... 

Output Sample #1

.*** 
x*#x 
###. 
.... 

Input Sample #2

...x 
###. 
#*** 
x..* 

Output Sample #2

No winning move 
Draw 

Input Sample #3

.### 
x#*x 
***. 
.... 

Output Sample #3

No winning move 
Losing 

Notes/Hints

Data Range

The input guarantees that the given position is valid.

Hints

BalticOI 2002 Day2 B.

You can score points on test cases without winning moves if and only if you pass at least half of the test cases with winning moves. (Note: Originally, the problem statement mentioned passing at least one, but here we follow the explanation in the original problem solution, which states "half".)

Due to the configuration of the custom scoring script, any verdict other than AC, WA, TLE, or MLE will result in a UKE.

Subtask #0 is the sample; Subtask #1 is the data.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
.*** #*.x ###. x...
样例输出
.*** x*#x ###. ....