![]() |
||||||||||
|
||||||||||
Big castleTime 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
Sample Output
Source | ||||||||||
|