QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 64 MB Total points: 100 Hackable ✓

#6789. また別の石取りゲーム

Statistics

Alice と Bob は、また別の石取りゲームをしています。このゲームの規則は以下のとおりです。

  • ゲームは $1$ から $n$ までの番号が付いた $n$ 個の石の山から始まります。$i$ 番目の山には $a_i$ 個の石があり、$b_i$ で表される特別な制約があります。

  • プレイヤーは交互に手を指します。2 人のプレイヤーに許される手は異なります。

  • Bob に許される手は、1 つの山から正の個数の石を取り除くことです。

  • Alice に許される手も、1 つの山から正の個数の石を取り除くことですが、その山の制約 $b_i$ によって制限されます。

    • $b_i = 0$ の場合、制約はありません。

    • $b_i = 1$ の場合、Alice はその山から奇数個の石だけを取り除くことができます。

    • $b_i = 2$ の場合、Alice はその山から偶数個の石だけを取り除くことができます。

    Bob には制約がないことに注意してください。

  • 許される手を指せないプレイヤーが負けます。

Alice が常に先手です。両者が最善を尽くした場合、どちらがゲームに勝つでしょうか?

入力

複数のテストケースがあります。入力の最初の行にはテストケース数を表す整数 $T$ が与えられます。各テストケースについて:

最初の行には、山の数を表す整数 $n$ ($1 \le n \le 10^5$) が与えられます。

2 行目には、各山の石の個数を表す $n$ 個の整数 $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$) が与えられます。

各テストケースの 3 行目には、各山の特別な制約を表す $n$ 個の整数 $b_1, b_2, \ldots, b_n$ ($0 \le b_i \le 2$) が与えられます。

すべてのテストケースにわたる $n$ の総和は $10^6$ を超えないことが保証されます。

この問題の入出力ファイルは大きいため、より高速な入出力方法を使用することを推奨します。例えば、C++ では cin/cout の代わりに scanf/printf を使えます。

出力

各テストケースについて、Alice が勝つ場合は “Alice”(引用符なし)を出力してください。それ以外の場合は “Bob”(引用符なし)を出力してください。

入出力例

入力 1

3
2
4 1
1 0
1
3
2
1
1
2

出力 1

Alice
Bob
Bob

注記

最初のテストケースでは、Alice は最初の山から 3 個の石を取り除き、そのあとゲームに勝つことができます。

2 番目のテストケースでは、Alice は偶数個の石しか取り除けないため、最初の手ですべての石を取り除くことはできません。そのため Bob は自分の手番で残った石をすべて取り除いて勝つことができます。

3 番目のテストケースでは、Alice はゲーム開始時にどの個数の石も取り除けないので、Bob が勝ちます。

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.