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

Big castle

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


Problem Description
  Cdfpysw, the king of alpaca, lives in a big castle. The castle contains n rooms and rooms are connected by corridors.
  One day, his friend Nanaya visit him with the dual horsetail robot. To welcome Nanaya, Cdfpysw decides to turn on all the lights of his castle. But because his castle is too big, it's not a easy job.
  Luckily, the castle has a system to control lights. When turn on/off a light, all the lights whose room is connected directly to this light's room will reverse the state.(If on, the light will be turned off. If off, the light will be turned on) But sometimes, if the system on, there is no way to turn on all lights in the castle. Now, Cdfpysw want to know if it is possible to turn on all lights if the system on.
 

Input
  The first line contains an integer n, indicating the number of rooms. (1 <= n <= 50000)
  The next line contains n integers. If the i_th integer is 1, the i_th room's light is on now and vice versa.
  The next n - 1 line, each line contains two integers u and v, indicating there is a corridor between the u_th room and v_th room.
  The input guaranteed that there is a road between any two rooms.
 

Output
  If it is possible to turn on all lights, print "Great Cdfpysw!". Otherwise print "Poor Nanaya!".
 

Sample Input
5 1 0 0 0 1 1 2 1 3 2 4 2 5
 

Sample Output
Great Cdfpysw!
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2025 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2025-03-29 00:16:34, Gzip enabled