QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 256 MB

#21383. 消失的逆序对

Statistics

Alice 和 Bob 正在一个排列上玩游戏,由 Alice 先手。

一个长度为 $n$ 的序列被称为排列,当且仅当 $1, 2, \ldots, n$ 中的每个整数都在该序列中恰好出现一次。

初始时,给定一个长度为 $n$ 的排列 $a_1, a_2, \ldots, a_n$。在游戏过程中的任意时刻,当前序列始终是某个长度为 $m$ 的排列。两名玩家轮流操作,每回合当前玩家必须从以下两种操作中选择一种执行:

  • 选择一个满足 $a_i > a_{i+1}$ 的下标 $i$($1 \le i < m$),并交换 $a_i$ 和 $a_{i+1}$;
  • 选择一个满足 $a_{i+1} = a_i + 1$ 的下标 $i$($1 \le i < m$),删除 $a_i$ 和 $a_{i+1}$,然后按照剩余元素的相对大小顺序对它们重新编号:将剩余元素中第 $k$ 小的元素重新编号为 $k$,使得剩余序列再次成为一个排列。

例如,假设当前排列为 $[2, 3, 4, 1]$。可以删除相邻元素 $2$ 和 $3$,剩下 $[4, 1]$;重新编号后,排列变为 $[2, 1]$。

无法执行任何操作的玩家输掉游戏。假设 Alice 和 Bob 都采取最优策略,请判断谁会获胜。

输入格式

本题单个测试点包含多组测试数据。

第一行包含一个整数 $T$($1 \le T \le 5000$),表示测试数据的组数。

对于每组测试数据:

  • 第一行包含一个整数 $n$($1 \le n \le 5000$)。
  • 第二行包含 $n$ 个整数 $a_1, a_2, \ldots, a_n$。保证 $a$ 是一个长度为 $n$ 的排列。

保证所有测试数据中 $n$ 的总和不超过 $5000$。

输出格式

对于每组测试数据,如果 Alice 获胜,输出 Alice;否则输出 Bob。

样例

输入格式 1

5
1
1
2
1 2
2
2 1
4
2 4 1 3
5
5 1 4 2 3

输出格式 1

Bob
Alice
Bob
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.