QOJ.ac

QOJ

Points totaux : 100 Indisponible

#1484. 吃巧克力游戏

Statistiques

Chomp 是一个双人策略游戏,在一个由较小的方块(单元格)组成的矩形巧克力板上进行。玩家轮流选择一个方块并将其“吃掉”(从板上移除),同时移除该方块上方和右侧的所有方块。左下角的方块是有毒的,被迫吃掉它的玩家输掉比赛。下图展示了一个 3x3 棋盘的游戏开始过程。$\mathbf{X}$ 表示有毒的方块。

如果一个游戏局面能够通过某种移动使对手进入失败局面,则该局面为获胜局面。如果一个游戏局面中,所有可能的移动都会导致对手进入获胜局面,或者导致自己吃掉有毒的方块(输掉比赛),则该局面为失败局面。

在上面的例子中,$1 \times 1$ 的局面和等边 L 型局面是失败局面(因为对手可以镜像当前玩家的操作)。

$3 \times 3$ 的不等边 L 型局面和 $1 \times n$ 局面是获胜局面。

本题的目标是“求解” $3 \times 100$ 的 Chomp 游戏。即对于每个可能的局面,确定它是获胜局面还是失败局面;如果是获胜局面,给出下一步的移动。

$3 \times 100$ Chomp 游戏中的一个局面由底行方块数 $p$、中间行方块数 $q$ 和顶行方块数 $r$ 确定,满足:

$$100 \ge p \ge q \ge r \ge 0$$

编写一个程序,对于 $3 \times 100$ Chomp 游戏的每个可能局面,确定它是获胜局面还是失败局面;如果是获胜局面,给出下一步的移动(即接下来要吃掉的方块)。

输入格式

输入的第一行包含一个整数 $P$ ($1 \le P \le 1000$),表示后续的数据集数量。每个数据集应被独立处理。

每个数据集由单行输入组成。它包含数据集编号 $K$,后跟底行方块数 ($p$)、中间行方块数 ($q$) 和顶行方块数 ($r$),各数之间由空格分隔。

输出格式

对于每个数据集,输出一行。如果输入局面是失败局面,输出数据集编号 $K$,后跟一个空格和字母 $\mathbf{L}$。否则(如果输入局面是获胜局面),输出数据集编号 $K$,后跟一个空格、字母 $\mathbf{W}$,以及导致对手进入失败局面的下一步移动的列号和行号。

样例

样例输入 1

4
1 3 3 3
2 3 1 0
3 3 2 0
4 97 64 35

样例输出 1

1 W 2 2
2 W 3 1
3 L
4 W 51 1

ou importez des fichiers un par un

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.