2657. Game

单点时限: 2.0 sec

内存限制: 256 MB

Flynn and oooccc1 are playing game some day. The game is played on a rooted graph which is an undirected graph with every edge attached by some path to a special vertex called the root or the ground. The ground is denoted in the figure that follows by a dotted line. You could see it from the figure.

On each step, one player could chop out one edge, and removing that edge and anything not connected to the ground. The one who have nothing to chop with fails.

Flynn is the one who is going to move. Help him by telling him if it is possible to win by carefully choose the edge to chop with.

输入格式

There are a few cases. Process to the end of file

Each case starts with N (1 <= N <= 1000) stand for the number of points.

The next line give N numbers, the i-th (i = 0 … N-1) of which represents its father nodes. The root nodes was the one with value -1.

输出格式

Print “YES” if could win if play optimally, and “NO” otherwise.

样例

Input
8
-1 1 2 2 -1 5 6 6
Output
NO

2 人解决,8 人已尝试。

2 份提交通过,共有 27 份提交。

9.6 EMB 奖励。

创建: 15 年,3 月前.

修改: 7 年,2 月前.

最后提交: 3 年,12 月前.

来源: N/A

题目标签