#P16251. [蓝桥杯 2026 省研究生组] 基态坍缩

[蓝桥杯 2026 省研究生组] 基态坍缩

Problem Description

A quantum chain is formed by connecting NN nodes in order. The nodes are numbered from the front end to the back end as 1∼N1 \sim N. The initial energy level of the ii-th node is a positive integer AiA_i.

Two control models, L and Q, play a game on this chain. Both use optimal strategies and take turns operating, with L moving first.

Each time it is a model’s turn, it must perform one “downgrade intervention” on the current back-end node of the quantum chain (that is, the last node of the current sequence), following these rules:

  • Let the current energy level of the back-end node be BB.
  • Its energy level must be reset to an integer xx such that 0≤x<B0 \leq x < B.
  • If after resetting, the node’s energy level becomes 00, then the node is immediately stripped from the chain. At this time, its previous node (if any) becomes the new back-end node.
  • If after resetting, the node’s energy level is greater than 00, then the node remains at the back end of the chain, waiting for later operations to further downgrade it.

The game continues until the quantum chain is completely stripped (that is, all nodes are removed). When it is a model’s turn to operate, if there are no nodes left on the chain, then that model is judged to lose because it cannot make a move, and the other side wins.

Please determine who will win in the end when both sides play optimally.

Input Format

The first line contains a positive integer TT, which denotes the number of testdata sets.
Then TT testdata sets follow. For each testdata set:

  • The first line contains a positive integer NN, which denotes the total number of nodes in the quantum chain for this game.
  • The second line contains NN positive integers A1,A2,…,ANA_1, A_2, \ldots, A_N, representing the initial energy levels of the nodes from the front end to the back end. Adjacent values are separated by a single space.

Output Format

For each testdata set, output one line with a single string. If control model L can win in the end, output L; otherwise, if model Q wins, output Q.

2
2
1 2
2
2 1
L
Q

Hint

Constraints and Notes

For 30%30\% of the testdata, 1≤T≤1001 \leq T \leq 100, 1≤N≤1031 \leq N \leq 10^3, 1≤Ai≤1031 \leq A_i \leq 10^3, and the sum of NN over all testdata does not exceed 5×1035 \times 10^3.

For all testdata, 1≤T≤1041 \leq T \leq 10^4, 1≤N≤1051 \leq N \leq 10^5, 1≤Ai≤1091 \leq A_i \leq 10^9, and the sum of NN over all testdata does not exceed 2×1052 \times 10^5.

Translated by ChatGPT 5