No.2044 Infinite Nim
タグ : / 解いたユーザー数 139
作問者 : 👑
hitonanode
platinum
Problem Statement
There are $N$ piles of stones, and the $i$-th pile contains $A_i$ stones. Note that the number of stones can be infinite. $A_i=−1$ means that the $i$-th pile contains infinitely many stones.
Sente Taro and Gote Jiro play a game. Starting with Sente Taro, they alternately perform the following operation.
-
Choose $1$ pile that contains at least $1$ stone and remove at least $1$ stone from it, so that the number of stones in the chosen pile becomes finite.
More precisely, when a pile with $x$ stones is chosen: if $x$ is finite, choose $1$ non-negative integer $y$ satisfying $y\lt x$ and set the number of stones in this pile to $y$. If $x$ is infinite, choose $1$ non-negative integer $y$ and set the number of stones in this pile to $y$.
The player who first becomes unable to make a move loses. Determine which of the $2$ players wins when they act optimally.
Constraints
- $1\le N\le 10^5$
- $1\le A_i\le 10^9$ or $A_i=-1$
- All input values are integers
Input
$N$ $A_1$ $A_2$ $\ldots$ $A_N$
Output
Print First if Sente Taro wins, and Second if Gote Jiro wins.
Sample
Sample 1
Input
4 1 3 5 7
Output
Second
The numbers of stones are finite.
Sample 2
Input
2 1 -1
Output
First
Sente Taro can remove stones from pile number $2$, which contains infinitely many stones, so that this pile contains $1$ stone.
Sample 3
Input
8 123 -1 456 -1 789 -1 -1 -1
Output
First
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。