QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 256 MB Total points: 100

#1644. 리버스 게임

Statistics

앨리스와 밥은 턴제 게임을 하고 있습니다. 게임의 규칙은 다음과 같습니다.

  1. 게임 시작 시 어떤 이진 문자열 $s$가 선택됩니다.
  2. 자신의 차례가 되면 플레이어는 $s$의 부분 문자열 $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$을 얻습니다. 밥은 이 문자열로 더 이상 움직임을 만들 수 없으므로 패배합니다.

두 번째 예제에서 앨리스는 어떠한 움직임도 만들 수 없으므로 패배합니다.

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.