F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Game

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 860    Accepted Submission(s): 314


Problem Description
  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.
 

Input
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.
 

Output
Print ˇ°YESˇ± if could win if play optimally, and ˇ°NOˇ± otherwise.
 

Sample Input
8 -1 1 2 2 -1 5 6 6
 

Sample Output
NO
 

Author
ZSTU
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 21:24:51, Gzip enabled