P9278 [AGM 2023 Qualifier] Another Game
Description
Charlie and Dan are playing a game on $N$ piles of stones numbered from $1$ to $N$ from left to right. Each pile contains a positive number of stones.
They take turns making moves, and Charlie moves first.
On each turn, a player takes a positive number of stones from the leftmost non-empty pile and moves them to the adjacent pile on the right. If, on a player's turn, the only non-empty pile is pile $N$, then that player loses the game.
If both players play optimally, who will win the game?
Input Format
The first line of input contains an integer $N(2 \le N \le 10^3)$, the number of piles.
The next line contains $N$ integers $v_1, v_2, v_3, ..., v_n(1 \le v_i \le 10^9)$, representing the number of stones in each pile.
Output Format
Output the name of the player who wins.
Explanation/Hint
Translated by ChatGPT 5