Terrorist attack in Seriousland
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
Time Limit: 2.0 s
Memory Limit: 512.0 MB
Description
The country Seriousland of serious people has \(N\) cities connected by \(N-1\) roads. The country is strongly protected by borders and guards, except some of the cities have weak issues in border security. Those cities are marked as vulnerable cities.
Thakur was appointed as an OC (officer in charge) of the Seriousland police force. On his first day of work, he got serious work to do. The city \(C\) was attacked by a group of terrorists, and Thakur has to arrest them. The police station is located in the city \(P\). It takes exactly 1 hour to travel from a city to any of its adjacent cities in Seriousland. Luckily, Thakur was able to hack the real-time location data of the terrorist group. Now he has to catch them before they reach into any of the vulnerable cities. Because if they reach into any of the vulnerable cities before Thakur, they may cross the border of Seriousland and cannot be arrested.
If Thakur enters a city at the same time or before the terrorist group, then he will be able to arrest them.
You are given the map of Seriousland and \(Q\) queries with the location of the attacked city \(C\) and the police station \(P\). In each query you have to print "weee" if it is possible for Thakur to arrest the terrorist group or "oops" otherwise.
Input
First line takes an integer \(N\) : number of cities
Second line takes \(N\) integers (0/1) : here 1 represents the \(i\)-th city is vulnerable and 0 represents the city is well protected
Next \(N-1\) line takes two integer \(u,v\) each : means there is a bidirectional road between city \(u\) and city \(v\)
Next line takes an ingeger \(Q\) : Number of queries
Next \(Q\) line takes two integer \(C,P\) each : the attacked city and the city where police station is located
\(2 <= N,Q <= 2*10^5\)
\(1 <= u,v <= N\)
\(1 <= C,P <= N\)
Output
For each query print "weee" if it is possible for Thakur to arrest the terrorists or print "oops" otherwise.
Sample
Input | Output |
---|---|
|
|
There exists only one vulnerable node which is node 3.
in first query: Terrorist group will be caught in node 2
in second query: they will be caught immidiately in node 3
in third query: thakur cannot catch them anyway
in fourth query: again they will be caught in node 2
LU IUJPC : Sylhet Division 2024 Replay Contest
- Status
- Done
- Rule
- ACM/ICPC
- Problem
- 11
- Start at
- 2024-12-10 09:00
- End at
- 2024-12-10 14:00
- Duration
- 5.0 hour(s)
- Host
- Partic.
- 63