#P16264. [蓝桥杯 2026 省 Python B 组] 奇偶博弈

    ID: 18284 远端评测题 3000ms 512MiB 尝试: 0 已通过: 0 显示难度普及 上传者: 标签>博弈论2026蓝桥杯省赛SG 函数

[蓝桥杯 2026 省 Python B 组] 奇偶博弈

Problem Description

Xiao Lan and Xiao Qiao are playing a game based on a sequence.

At the beginning, a sequence of length NN, W1,W2,…,WNW_1, W_2, \dots, W_N, is given. Every element in the sequence is a positive odd integer.

Xiao Lan moves first, and they take turns to make moves. In each move, the current player needs to choose an element WiW_i in the sequence that is strictly greater than 00, and replace it with a non-negative integer Wi′W_i' that is strictly smaller than it (that is, 0≤Wi′<Wi0 \leq W_i' < W_i).

This replacement must strictly satisfy the following parity constraints:

  1. If the chosen WiW_i is odd, then it must be replaced with Wi−1W_i - 1.
  2. If the chosen WiW_i is even, then the new number Wi′W_i' must also be even.

When it is a player's turn, if they cannot make any legal replacement, then they lose the game and the other player wins.

Assume both Xiao Lan and Xiao Qiao are extremely smart and always use the optimal strategy. Determine who will win this game in the end.

Input Format

The first line contains an integer TT, indicating the number of test cases.

Then TT test cases follow.

For each test case:

  • The first line contains an integer NN, indicating the length of the sequence.
  • The second line contains NN positive odd integers W1,W2,…,WNW_1, W_2, \dots, W_N, separated by spaces.

Output Format

For each test case, output one line. If Xiao Lan wins, output L; if Xiao Qiao wins, output Q.

2
2
5 1
2
1 1
L
Q

Hint

Constraints

For all testdata, 1≤T≤1031 \leq T \leq 10^3, 1≤N≤1051 \leq N \leq 10^5, 1≤Wi≤1091 \leq W_i \leq 10^9.

It is guaranteed that the sum of NN over all test cases does not exceed 2×1052 \times 10^5, and it is guaranteed that all WiW_i in the initial input are odd.

Translated by ChatGPT 5