luogu#P9003. [RC-07] Game Theory
[RC-07] Game Theory
Problem Description
You are given a 01 sequence of length , and the sequence contains an even number of 1. NIT and TIN take turns performing the following operation, with NIT going first:
- Choose a position such that the interval contains an odd number of
1. Then choose a position . Flip both and (that is,0becomes1, and1becomes0).
When all elements in the whole sequence become 0, the player whose turn it is cannot make a move and thus loses. Assume both NIT and TIN are extremely smart; who will win? It can be proven that the game will always end.
can be very large, but the number of 1 in the sequence does not exceed .
Input Format
This problem has multiple test cases.
The first line of input contains the number of test cases .
Then follows the description of each test case. The first line of each test case contains two positive integers , where is the number of 1 in the sequence, and it is guaranteed that is even.
The next line contains strictly increasing positive integers describing the indices of these 1. Indices start from .
Output Format
For each test case, output one line with a string NIT or TIN, indicating the winner’s name.
3
4 2
1 3
4 4
1 2 3 4
10 4
1 3 7 8
NIT
TIN
NIT
Hint
Explanation of the samples
In the first test case, NIT can choose to turn all positions into 0, making TIN unable to move.
In the second test case, no matter how NIT plays first, there will be exactly two positions with 1 left. TIN only needs to choose these two remaining positions to turn all positions into 0.
In the third test case, one possible game process is as follows (note that in this process, each move is not necessarily optimal):
- NIT chooses and flips these two positions. Now the positions of
1are . - TIN chooses and flips these two positions. Now the positions of
1are . - NIT chooses and flips these two positions. Now the positions of
1are . - TIN chooses and flips these two positions. Now the positions of
1are . - NIT chooses and flips these two positions. Now the positions of
1are . - TIN chooses and flips these two positions. Now the positions of
1are . - NIT chooses and flips these two positions. Now there is no
1in the sequence. - TIN cannot move, and NIT wins.
Constraints
For all testdata, , , , . It is guaranteed that is even, and the indices that are 1 are given in increasing order.
- Subtask 1 ( point): , .
- Subtask 2 ( points): The sequence is all
1. - Subtask 3 ( points): , .
- Subtask 4 ( points): .
- Subtask 5 ( points): No additional constraints.
Translated by ChatGPT 5