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

26023번 - Mirror Madness 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 (추가 시간 없음) 1024 MB26171568.182%

문제

Yesterday, a new attraction was opened at the local funfair: a hall of mirrors. This is a labyrinth in which all the walls are covered with mirrors so that visitors lose their sense of direction in a sea of reflections. The layout of the labyrinth can be described by a polygon with all sides parallel to either the x-axis or y-axis.

On the opening day, many visitors got so lost that the ride operators had to intervene and help them find their way out. To better understand where visitors get lost the most, the operators decided to install a monitoring system. This system involves an invisible laser beam running through the hall of mirrors at foot level, so that the movement of the visitors can be tracked by observing when and where the laser beam gets interrupted.

The laser beam starts at some boundary point of the polygon at an angle of 45ドル$ degrees to the wall. Whenever it hits a mirror, it bounces off in a 90ドル$ degree angle. To get their monitoring system to work, the operators are planning to install sensors at each of the first $m$ bouncing points of the laser beam. Find the locations where the sensors need to be installed.

Figure M.1: Illustration of the second sample case.

입력

The input consists of:

  • One line with two integers $n$ and $m$ (1ドル \le n,m \le 5\cdot 10^5$), the number of vertices of the polygon and the number of bounces.
  • $n$ lines, each with two integers $x$ and $y$ giving the coordinates of one vertex.
  • One line with integers $x_s$ and $y_s,ドル the coordinates of the starting point.

Additionally, the input satisfies the following constraints:

  • The vertices of the polygon are given in counterclockwise order.
  • The edges of the polygon do not touch or intersect each other, except for consecutive edges, which share their endpoints.
  • The edges of the polygon alternate between horizontal and vertical.
  • The perimeter (the total length of all sides) of the polygon does not exceed 10ドル^6$.
  • All coordinates in the input have absolute value at most 10ドル^6$.
  • All coordinates of the vertices of the polygon and exactly one coordinate of the starting point are even (so the laser never hits a vertex of the polygon).
  • The starting point is on the boundary of the polygon.
  • The initial direction of the laser beam is $(1,1),ドル and this points inside the polygon.

출력

Output $m$ lines, each with two integers $x$ and $y,ドル giving the coordinates of the bounce locations in order.

제한

예제 입력 1

4 6
0 0
10 0
10 10
0 10
1 0

예제 출력 1

10 9
9 10
0 1
1 0
10 9
9 10

예제 입력 2

10 10
-2 -2
8 -2
8 8
4 8
4 0
2 0
2 6
-4 6
-4 2
-2 2
4 1

예제 출력 2

8 5
5 8
4 7
8 3
3 -2
-4 5
-3 6
2 1
-1 -2
-2 -1

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > German Collegiate Programming Contest > GCPC 2022 M번

  • 문제를 만든 사람: Paul Wild
(追記) (追記ここまで)

출처

대학교 대회

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

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