Problem H
Water Decor

The Pokemon Aquarium is finally remodeling! To commemorate
its
The decoration is quite an interesting design and can be
modeled as a series of non-overlapping circles in the square
Water always flows directly downwards. If it hits a circle, it will flow differently depending on where it hits the circle.
-
If it hits the left half of the circle, it will flow along the left side and continue flowing downwards from the left half
-
If it hits the right half of the circle, it will flow along the right side and continue flowing downwards from the right half
-
If it hits the top of the circle, it will flow along both the left and right side of the circles and continue flowing downwards from both halves
Squirtle loves to watch the water flow in the decoration. He
wonders, if all the water dispensers between
Input
The first line of input contains two integers,
It is guaranteed all circles will be fully contained inside the
square with a bottom-left corner at
Output
Output
Sample Input 1 | Sample Output 1 |
---|---|
1 3 1 1 1 0 0 0 1 1 1 |
1 2 2 |
Sample Input 2 | Sample Output 2 |
---|---|
2 4 1 1 1 4 5 3 0 0 0 1 1 1 5 6 |
1 2 2 1 |