There are
You planned
You are a werewolf. You have two forms: human form and wolf form. At the beginning of each trip you are in human form. At the end of each trip, you must be in wolf form. During the trip you have to transform (change from human form to wolf form) exactly once. You can transform only when you are in some city (possibly
Living as a werewolf is not easy. You must avoid low-populated cities when you are in human form, and avoid highly-populated cities when you are in wolf form. For each trip
Your task is to determine, for each trip, whether it is possible to travel from the city
Implementation details
You should implement the following function:
std::vector<int> check_validity(int N, std::vector<int> X, std::vector<int> Y, std::vector<int> S, std::vector<int> E, std::vector<int> L, std::vector<int> R)
: the number of cities. and : arrays of length . For each , the cityX[j]
is directly connected to the cityY[j]
by a road. , , , and : arrays of length , representing the trips.
Note that the values of
The function check_validity
is called exactly once for each test case. This function should return an array
Example
Let
check_validity(6, {5, 1, 1, 3, 3, 5}, {1, 2, 3, 4, 0, 2}, {4, 4, 5}, {2, 2, 4}, {1, 2, 3}, {2, 2, 4})
For the trip
- Start at city
(You are in human form) - Move to the city
(You are in human form) - Move to city
(You are in human form) - Transform yourself into wolf form (You are in wolf form)
- Move to the city
(You are in wolf form)
For the trips
Hence, your program should return [1, 0, 0]
.
Constraints
- For each
- You can travel from any city to any other city by using roads.
- Each pair of cities are directly connected by at most one road. In other words, for all
, and . - For each
Subtasks
Subtask | Points | Constraints |
---|---|---|
No additional constraints |
Sample Grader
The sample grader reads the input in the following format:
- line
: - line
: - line
:
The sample grader prints the return value of check_validity
in the following format:
- line
:
Comments