#P12623. [NAC 2025] Geometry Rush
[NAC 2025] Geometry Rush
题目描述
You are playing the summer's hottest rhythm-based action platformer---Geometry Rush! The game is played on a 2D plane. Your character begins at and every second must move at a -degree angle either up-right or down-right, which takes your character from position to or respectively. You can change which direction you move every second, but not in between moves. There are obstacles protruding from the floor and ceiling that you must dodge. You win the game if, after seconds, you reach the line without having touched any obstacles on the way.
The play area extends vertically from to . Obstacles are two polygonal curves: one curve starts at and ends at and represents a ceiling of varying height. The values of the vertices of this curve are non-decreasing, and the values lie between and inclusive. A second polygonal curve starts at and ends at and represents the floor. Its vertices satisfy similar constraints.
Your character is a point of negligible extent: you can move from position to so long as the line segment between your start and end position does not intersect either obstacle. (Exactly touching either polygonal curve counts as intersecting an obstacle, and loses the game.)
You have played a lot of games of Geometry Rush. To keep the game interesting, you have started to set challenges for yourself. For example: you win the game no matter where you cross the goal line. But for what maximum value of can you win the game by crossing at without touching any obstacles on the way? For what minimum value? Compute these numbers.
输入格式
The first line of the input contains four space-separated integers , , , and . The first two integers () are the number of vertices in the ceiling and floor polygonal curves, respectively. The second two integers () are the width and height of the play area, as described above.
The next lines each contain two space-separated integers and (; ): the coordinates of the vertices of the ceiling polygonal curve, in order from left to right. It is guaranteed that the first vertex is at and the last vertex is at .
The next lines each contain two space-separated integers and (; ): the coordinates of the vertices of the floor polygonal curve, in order from left to right. It is guaranteed that the first vertex is at and the last vertex is at .
For both polygonal curves: the coordinates are non-decreasing, all vertices are distinct, and the curve does not self-intersect. Neither curve intersects . (The floor and ceiling curves might intersect each other, in which case the game is unwinnable.)
输出格式
If it is impossible to win the game, print . Otherwise, print two space-separated integers: the minimum and maximum values that the player could reach at without losing the game by touching an obstacle along the way.
4 4 5 5
0 5
0 2
5 2
5 5
0 -5
0 -2
5 -2
5 -5
-1 1
4 4 6 5
0 5
0 2
6 2
6 5
0 -5
0 -2
6 -2
6 -5
0 0
3 3 7 5
0 5
5 -1
7 5
0 -5
2 1
7 -5
impossible
4 3 5 5
0 5
0 2
5 2
5 5
0 -5
3 -1
5 -5
-1 1