#P15035. [UOI 2021 II Stage] 游戏

    ID: 16967 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 显示难度提高 上传者: 标签>博弈论2021字典树 TrieUOI(乌克兰)

[UOI 2021 II Stage] 游戏

Background

Double experience: https://www.luogu.com.cn/problem/AT_arc087_c.

Problem Description

Cossack Moustache has come up with another problem for competitive programmers.

You are given a set of nn strings s1,s2,…,sns_1, s_2, \ldots, s_n and a number kk.

A set of strings is called beautiful if and only if:

  • Each string consists only of 00 and 11;
  • The length of each string is at most kk;
  • No string is a prefix of another string.

The given set is beautiful.

Alice and Bob are playing the following game. They take turns to make a move. In each move, they may add a string to the set, provided that after adding it, the set is still beautiful. The player who cannot make a move loses.

Alice moves first. Help determine who will win if both players play optimally.

Input Format

The first line contains two integers nn (0≤n≤105,1≤k≤10180 \le n \le 10^5, 1 \le k \le 10^{18}), which are the number of strings in the set and the maximum allowed length of strings in a beautiful set.

The next nn lines follow. The ii-th line contains a string sis_i (1≤∣si∣≤1061 \le |s_i| \le 10^6).

It is guaranteed that ∑i=1n∣si∣≤106\sum_{i=1}^{n}{|s_i|} \le 10^6.

It is also guaranteed that the initial set is beautiful.

Output Format

If Alice wins, output Alice. If Bob wins, output Bob.

2 3
01
000
Bob
3 3
000
1
01
Alice
2 1
0
1
Bob

Hint

Scoring

  • (2 points): n=0n = 0.
  • (6 points): k=2k = 2.
  • (8 points): k=3k = 3.
  • (12 points): k≤10k \le 10.
  • (17 points): k≤20k \le 20.
  • (20 points): k≤104k \le 10^4.
  • (35 points): No additional constraints.

Translated by ChatGPT 5