QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 512 MB Total points: 100 Difficulty: [show]

#2213. Knight

الإحصائيات

有一个 $n$ 行 $m$ 列的棋盘。棋盘上的一些格子是损坏的。棋盘上有两枚棋子,分别由 Alice 和 Bob 控制。棋子的移动由两个参数 $r$ 和 $c$ 决定。在每一步中,Alice 或 Bob 可以将他们的棋子移动到水平距离为 $r$、垂直距离为 $c$,或者水平距离为 $c$、垂直距离为 $r$ 的格子。

Alice 和 Bob 轮流进行游戏,Alice 先手。在每一回合中,玩家移动自己的棋子。但是,玩家不能将棋子移动到损坏的格子或被对方棋子占据的格子上。

此外还有一个限制:棋子的配置可以看作一个有序对 $(a, b)$,其中 $a$ 是 Alice 的棋子所在位置,$b$ 是 Bob 的棋子所在位置。禁止重复出现之前已经出现过的配置。

如果一名玩家在轮到自己时无法移动,则该玩家输掉比赛。假设双方都采取最优策略,确定获胜者。

输入格式

第一行包含四个整数 $n, m, r$ 和 $c$ ($1 \le n, m \le 1000, 0 \le r < n, 0 \le c < m$)。

接下来的 $n$ 行,每行包含一个长度为 $m$ 的字符串。这些行共同描述了棋盘。每个格子有四种类型:

  • “@”:该格子已损坏。
  • “.”:该格子未损坏。
  • “A”:该格子未损坏,是 Alice 棋子的起始位置。
  • “B”:该格子未损坏,是 Bob 棋子的起始位置。

保证棋盘上 “A” 和 “B” 各出现且仅出现一次。

输出格式

输出获胜者的名字:“Alice” 或 “Bob”。

样例

输入 1

2 3 1 2
A@.
B@.

输出 1

Alice

说明 1

第一步,Alice 将棋子移动到格子 $(2, 3)$。 第二步,Bob 将棋子移动到格子 $(1, 3)$。 第三步,Alice 将棋子移回格子 $(1, 1)$。 第四步,Bob 不能将棋子移回格子 $(2, 1)$,因为这会产生有序对 $(1, 1), (2, 1)$,这与初始位置相同。Alice 获胜。

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.