z-game
Two players are playing a game with stones. There are N grups of stones. At first, the groups contain num[k] , 0 <= k <= N - 1, stones. A player makes a move by choosing three numbers (a, b, []), such that 0 <= a < b <= c <= N - 1, and num[a] > 0. after he has chosen the numbers he takes away one stone from the a-th group and adds one stone to the b -th and c-th. The winner is the player that has made the last possible move - the loser is the player who has no moves left
Write a program that will, for the inital values given for the group sizes, determine if the player who has the first move has a winning strategy. If he has one, you should output the first move that the first player must make in order to win. If there are more possible moves that ensure the winning strategy, then output the one that has the smallest value of a. If there are more of those, then output the one with the smallest value of b, and finally if there are more, then output the one with the smallest value of c.
Important: The groups of stones are indexed with numbers 0 to N - 1.
[c]4
0 1 0 5
Output:
1 2 25
1000 1000 1000 1000 1000Output:
-1Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.