QOJ.ac

QOJ

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

#2213. ナイト

Statistics

$n$ 行 $m$ 列のチェス盤があります。チェス盤の一部のマスは壊れています。チェス盤には 2 つのナイトがあり、それぞれ Alice と Bob が操作します。ナイトの移動方法は 2 つのパラメータ $r$ と $c$ で決まります。各手で、Alice または Bob は自分のナイトを、水平方向に $r$ マス、垂直方向に $c$ マス離れたマス、または垂直方向に $r$ マス、水平方向に $c$ マス離れたマスへ移動できます。

Alice と Bob は Alice から始めて交互に手を指します。各手番で、プレイヤーは自分のナイトを動かします。ただし、壊れたマスや、もう一方のナイトがいるマスへは移動できません。

さらに制約があります。ナイトの配置は順序対 $(a,b)$ とみなせます。ここで $a$ は Alice のマス、$b$ は Bob のマスです。以前に現れた配置を繰り返すことは禁止されています。

自分の手番で移動できないプレイヤーは負けます。両者が最適にプレイした場合の勝者を求めてください。

入力

最初の行には 4 つの整数 $n$、$m$、$r$、$c$ が与えられます($1 \le n,m \le 1000$、$0 \le r<n$、$0 \le c<m$)。

続く $n$ 行には、それぞれ長さ $m$ の文字列が与えられます。これらの行はチェス盤を表します。各マスには次の 4 種類があります。

  • 「@」:壊れたマスです。
  • 「.」:壊れていないマスです。
  • 「A」:壊れていないマスで、Alice のナイトの初期位置です。
  • 「B」:壊れていないマスで、Bob のナイトの初期位置です。

チェス盤には「A」と「B」がそれぞれちょうど 1 回現れることが保証されます。

出力

勝者の名前「Alice」または「Bob」を出力してください。

入出力例

入力 1

2 3 1 2
A@.
B@.

出力 1

Alice

注記

1 手目で Alice はナイトをマス $(2,3)$ へ移動します。

2 手目で Bob はナイトをマス $(1,3)$ へ移動します。

3 手目で Alice はナイトをマス $(1,1)$ へ戻します。

4 手目で 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.