There are
Fatima is planning to visit all of the attractions in three days. She already decided that
she wants to visit
Fatima would like to find the sets
Help Fatima find a valid partition of the attractions (given
Implementation details
You should implement the following procedure:
std::vector<int> find_split(int n, int a, int b, int c, std::vector<int> p, std::vector<int> q)
: the number of attractions. , , and : the desired sizes of sets , , and . and : arrays of length , containing the endpoints of the roads. For each , and are the two attractions connected by road .- This procedure should return an array of length
. Denote the array by . If there is no valid partition, should contain zeros. Otherwise, for , should be one of , , or to denote that attraction is assigned to set , , or , respectively.
Examples
Example 1
Consider the following call:
find_split(9, 4, 2, 3, {0, 0, 0, 0, 0, 0, 1, 3, 4, 5}, {1, 2, 3, 4, 6, 8, 7, 7, 5, 6})
A possible correct solution is
Example 2
Consider the following call:
find_split(6, 2, 2, 2, {0, 0, 0, 0, 0}, {1, 2, 3, 4, 5})
No valid partition exists. Therefore, the only correct answer is
Constraints
- There is at most one road between each pair of attractions.
- It is possible to travel between any pair of attractions through the roads.
and for
Subtasks
- (
points) Each attraction is an endpoint of at most two roads. - (
points) - (
points) - (
points) , - (
points) No additional constraints.
Sample grader
The sample grader reads the input in the following format:
- line
: - line
: - line
(for ):
The sample grader prints a single line containing the array returned by find_split
.
Comments