Attack
InterviewTime limit2sMemory limit1024 MB
Given a road network and the vampire clan in each city, decide whether the defenders of the attacked city can hold out against a werewolf army that loses min(t, a, b) per day.
- Level
Medium5 of 10
- Topics
- BFS, Simulation, Graph
- Solved
- No attempts yet
Problem
Everyone knows that vampires exist. Yet nobody stops to think about how close these creatures live. The twilight kingdom has cities, and some pairs of cities are connected by two-way roads. Each city has its own vampire clan, which contains vampires.
Long ago, the vampires drove all werewolves out of the kingdom, which made the werewolves their bitter enemies. The werewolves did not like this. They decided to unite into one squad and attack a city. The attacking squad contains werewolves.
However, since vampires always act together, the werewolves doubt that the attack will succeed. They have come to you for help. Vampires can move between two cities connected by a road in one day. Also, during one day of battle, vampires defending the besieged city die, and the same number of werewolves die, where is the current size of the vampire group, is the current size of the werewolf group, and is a constant. Using this information, determine whether the vampires can defend the city. A city is besieged if there is a moment when more than zero werewolves are attacking it and zero vampires are defending it.
Input
The first line contains three integers: (), the number of cities, (), the number of roads, and (), the number of vampires and werewolves that die in one day of battle. The second line contains exactly integers (), the number of vampires in the -th city. The next lines describe the roads, each with two city numbers connected by a road. The last line contains the number of the attacked city and (), the size of the werewolf army.
Output
Print <> if the vampires can defend their city, and <> otherwise.
Hint
Note that if all vampires in the city die, and a new group arrives from a neighboring city the next day, the vampires still lose.