#P16251. [蓝桥杯 2026 省研究生组] 基态坍缩
[蓝桥杯 2026 省研究生组] 基态坍缩
Problem Description
A quantum chain is formed by connecting nodes in order. The nodes are numbered from the front end to the back end as . The initial energy level of the -th node is a positive integer .
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 .
- Its energy level must be reset to an integer such that .
- If after resetting, the node’s energy level becomes , 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 , 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 , which denotes the number of testdata sets.
Then testdata sets follow. For each testdata set:
- The first line contains a positive integer , which denotes the total number of nodes in the quantum chain for this game.
- The second line contains positive integers , 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 of the testdata, , , , and the sum of over all testdata does not exceed .
For all testdata, , , , and the sum of over all testdata does not exceed .
Translated by ChatGPT 5