#P3185. [HNOI2007] 分裂游戏
[HNOI2007] 分裂游戏
Description
Congcong and Ruirui have become obsessed with a game called Split.
The rules are as follows: There are bottles labeled . Bottle initially contains chocolate beans. The two players take turns. On each turn, a player chooses three bottles with indices such that and , and bottle must contain at least bean. The player removes one bean from bottle and adds one bean to each of bottles and (note that may equal ). If it is a player’s turn and they cannot make a move following the rules, they lose. The winner takes all the chocolate beans.
Congcong moves first. He wants to know whether he can force a win given the initial numbers of beans in each bottle. He also wants you to tell him how to play the first move, and, to ensure victory, how many different first moves there are.
Input Format
The first line of input contains an integer , the number of test cases.
For each test case, the first line contains the number of bottles . The next line contains space-separated non-negative integers, the number of beans in each bottle.
Output Format
For each test case, output two lines. The first line contains three integers separated by single spaces, representing the indices that should be chosen on the first move to guarantee a win. If there are multiple valid answers, output the lexicographically smallest triple. If it is impossible to win no matter what, output three separated by single spaces.
The second line contains the number of distinct first moves that ensure a win.
2
4
1 0 1 5000
3
0 0 1
0 2 3
1
-1 -1 -1
0
Hint
Constraints: , , .
Translated by ChatGPT 5
京公网安备 11011102002149号