QOJ.ac

QOJ

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

#2213. 馬

Statistics

有一個 $n$ 行 $m$ 列嘅棋盤,棋盤上有啲格爛咗。棋盤上有兩隻馬,分別由 Alice 同 Bob 控制。馬點樣行,由兩個參數 $r$ 同 $c$ 決定。每一步,Alice 或 Bob 可以將自己隻馬移去橫向相距 $r$ 格、直向相距 $c$ 格嘅格,或者直向相距 $r$ 格、橫向相距 $c$ 格嘅格。

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

說明

第一步,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.