Game of Piles Version 2 Problem Code: GAMEOFPILES2 There are N piles where the th pile consists of A; stones. Chef and C
Posted: Sat Jul 09, 2022 11:49 am
Game of Piles Version 2 Problem Code: GAMEOFPILES2 There are N piles where the th pile consists of A; stones. Chef and Chefina are playing a game taking alternate turns with Chef starting first. In his/her turn, a player can choose any non-empty pile and remove exactly 1 stone from it. The game ends when exactly 2 piles become empty. The player who made the last move wins. Determine the winner if both players play optimally. Input Format Su
Input Format . The first line of input will contain a single integer T, denoting the number of test cases. • Each test case consists of multiple lines of input. o The first line of each test case contains a single integer IV denoting the number of piles. o Next line contains N space-separated integers A1, A2,..., AN- denoting the number of stones in each pile. Output Format For each test case, output CHEF if Chef wins the game, otherwise output CHEFINA. Note that the output is case-insensitive i.e. CHEF, Chef, cHeF, and chef are all considered the same. 4 Constraints .1≤T≤ 1000 • 2≤N≤ 105 • 1≤A, < 10⁰
• 1≤T≤ 1000 • 2≤N≤ 105 • 1 ≤ A ≤ 10⁹ • Sum of N over all test cases does not exceed 2-105. Sample Input 1 2 2 5 10 3 113 Sample Output 1 CHEF CHEFINA Explanation Test Case 1: The game will end when both piles become empty. Thus, the game will last exactly 15 moves with last move made by Chef. Test Case 2: It can be shown that Chefina has a winning strategy.