Logo
(追記) (追記ここまで)

34268번 - Geometry Rush 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB12111191.667%

문제

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 $(0,0)$ and every second must move at a 45ドル$-degree angle either up-right or down-right, which takes your character from position $(x,y)$ to $(x+1,y+1)$ or $(x+1, y-1)$ 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 $w$ seconds, you reach the line $x=w$ without having touched any obstacles on the way.

The play area extends vertically from $y=-h$ to $y=h$. Obstacles are two polygonal curves: one curve starts at $(0,h)$ and ends at $(w,h)$ and represents a ceiling of varying height. The $x$ values of the vertices of this curve are non-decreasing, and the $y$ values lie between $-h$ and $h$ inclusive. A second polygonal curve starts at $(0,-h)$ and ends at $(w,-h)$ and represents the floor. Its vertices satisfy similar constraints.

Your character is a point of negligible extent: you can move from position $(x,y)$ to $(x+1,y\pm 1)$ 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 $x=w$ goal line. But for what maximum value of $y$ can you win the game by crossing at $(w,y)$ 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 $n,ドル $m,ドル $w,ドル and $h$. The first two integers (3ドル \leq n, m \leq 10^{5}$) are the number of vertices in the ceiling and floor polygonal curves, respectively. The second two integers (3ドル \leq w, h \leq 10^{5}$) are the width and height of the play area, as described above.

The next $n$ lines each contain two space-separated integers $x$ and $y$ (0ドル \leq x \leq w$; $-h \leq y \leq h$): 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 $(0,h)$ and the last vertex is at $(w,h)$.

The next $m$ lines each contain two space-separated integers $x$ and $y$ (0ドル \leq x \leq w$; $-h \leq y \leq h$): 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 $(0,-h)$ and the last vertex is at $(w,-h)$.

For both polygonal curves: the $x$ coordinates are non-decreasing, all vertices are distinct, and the curve does not self-intersect. Neither curve intersects $(0,0)$. (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 impossible. Otherwise, print two space-separated integers: the minimum and maximum $y$ values that the player could reach at $x=w$ without losing the game by touching an obstacle along the way.

제한

예제 입력 1

4 4 5 5
0 5
0 2
5 2
5 5
0 -5
0 -2
5 -2
5 -5

예제 출력 1

-1 1

예제 입력 2

4 4 6 5
0 5
0 2
6 2
6 5
0 -5
0 -2
6 -2
6 -5

예제 출력 2

0 0

예제 입력 3

3 3 7 5
0 5
5 -1
7 5
0 -5
2 1
7 -5

예제 출력 3

impossible

예제 입력 4

4 3 5 5
0 5
0 2
5 2
5 5
0 -5
3 -1
5 -5

예제 출력 4

-1 1

힌트

출처

ICPC > Regionals > North America > North America Championship > North America Championship 2025 D번

  • 문제를 만든 사람: Yen-Hsiang Chang
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /