#bzoj4134. ljw和lzr的hack比赛
ljw和lzr的hack比赛
Title Description
Splitting the grass and shooting the wax lamp red, worshiping the god Lzhr;
The clear sand white bird flew back and knelt long before the giant god Ljw.
LZR, also known as the hack maniac QMQMQMQM, is well-known to many people.
Although LJW is not as famous as LZR, it also has one of the top hacks in competitions such as CF and BC.
These two experts from SD have decided to have a hack game today. After research, they decided to hack the problem that another god of SD, Jzh, had done.
We assume that jzh has already solved problems. These questions form a tree structure due to the connections between knowledge points. The problem (A+B problem) is the root of this tree.
Because SLYZ also has many skilled hackers, some of the n problems solved by JZH have already been hacked.
Now Ljw takes the lead, and the two of them take turns operating. One operation is to select a question that has not been hacked before, and then hack all the questions on the path from to that have not been hacked before.
The operator cannot input.
We assume that both LJW and LZR have incredibly high intelligence (which is also true) and will take actions that are most beneficial to themselves.
Ljw certainly wants to win this game! So he wanted to calculate whether he could ultimately win the game. If he can win, he also wants to know which questions he chooses as the first step while ensuring his victory.
Such a simple question, of course the god knows. But he wants to test you.
Input format
The first line is an integer , representing the number of problems solved by jzh Shen Ben.
The second line contains n integers, each of which is either 0 or 1. The th number is 0, indicating that the th problem has not been hacked yet, and the th number is , indicating that the th problem has been hacked by the slyz expert. The next lines describe the tree formed by the questions that jzh has done. Each line contains two integers , where represents an edge between the th question and the th question.
Output format
If LJW cannot win the game, output .
Otherwise, output all question numbers in ascending order. can be selected as the first step when ljw guarantees a win.
Example
8
1 1 0 1 0 0 1 0
1 2
1 3
2 6
3 4
3 5
5 7
7 8
5
Data scope and agreement
Data range: .