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.