#C9858. Optimal Integer Equilibration Game
Optimal Integer Equilibration Game
Optimal Integer Equilibration Game
Jack and Jill are given a sequence of integers. In each turn, a player may increment or decrement any element by 1. The players take turns, with Jack moving first. The objective is to make all the elements equal. The game ends as soon as all the elements have the same value, and if it is Jack's turn at that moment, then Jack is declared the winner; otherwise, Jill wins.
It can be proven that when both players play optimally, the outcome depends solely on the parity of the number of elements \(n\) in the sequence. Specifically, if \(n\) is even then Jack wins, and if \(n\) is odd then Jill wins.
inputFormat
The input begins with an integer \(T\) (the number of test cases). Each test case is described by two lines:
- The first line contains a single integer \(n\), the number of integers in the sequence.
- The second line contains \(n\) space-separated integers representing the sequence.
outputFormat
For each test case, output a single line containing the winner of the game. The output should be either Jack
or Jill
based on the rules described above.
2
3
1 2 3
4
4 4 4 4
Jill
Jack
</p>