QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 256 MB Points totaux : 100

#1644. リバースゲーム

Statistiques

アリスとボブはターン制のゲームを行っています。ゲームのルールは以下の通りです。

  1. ゲームの開始時に、ある二進文字列 $s$ が選ばれます。
  2. 自分のターンにおいて、プレイヤーは $s$ の部分文字列 $t$ を選ばなければなりません。$t$ は $10, 110, 100, 1010$ のいずれかと等しくなければなりません。その後、プレイヤーはその $t$ を反転させます。例えば、$s = 010101$ の場合、プレイヤーは部分文字列 $t = 1010$ を選択して反転させ、$s = 001011$ を得ることができます。
  3. 手番で動かせなくなった(適切な部分文字列 $t$ を選べなくなった)プレイヤーが負けとなります。
  4. プレイヤーはパスをすることができません。

アリスが先手であるとき、どちらのプレイヤーに必勝戦略があるでしょうか。

文字列 $a$ が文字列 $b$ の部分文字列であるとは、$b$ の先頭からいくつか(0個でもすべてでもよい)、および末尾からいくつか(0個でもすべてでもよい)の文字を削除することで $a$ が得られることを指します。

入力

入力の唯一の行には、アリスとボブがプレイする文字列 $s$ ($1 \le |s| \le 10^6$) が含まれます。

出力

アリスが勝つ場合は Alice と出力してください。そうでない場合は Bob と出力してください。

入出力例

入力 1

010

出力 1

Alice

入力 2

1111

出力 2

Bob

入力 3

1010

出力 3

Bob

入力 4

1010001011001

出力 4

Alice

注記

最初の例では、アリスは $010$ の部分文字列 $10$ を選んで反転させ、$001$ を得ることができます。ボブはこの文字列では動かすことができず、負けとなります。

2番目の例では、アリスは一度も動かすことができず、負けとなります。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#316EditorialOpen题解jiangly2025-12-14 07:03:28View

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.