아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Intertwined

시간 제한1초메모리 제한1024 MB

요약
길이 d인 밧줄이 원점을 중심으로 반시계 방향으로 회전하다가 닿는 기둥을 축으로 삼아 다시 회전하는 과정을 반복할 때, 마지막으로 회전 축이 된 기둥의 번호를 출력하거나 없으면 -1을 출력한다.
난이도

보통10점 중 7점

유형
기하, 정렬, 이분 탐색, 시뮬레이션
정답자
아직 제출이 없습니다

문제

NCPC (Nordic Cargo Plane Control) are testing a new engine for their cargo planes. To this end they have bound a strong and sturdy infinitely thin rope to the centre of their testing platform, and to the engine. We will place a coordinate system onto this testing platform such that the rope is bound at the origin and lays along the positive xx-axis to (d,0)(d, 0). On this testing platform there are also a number of infinitely thin pillars that can stop the rope, but ignore the engine. As the engine is started it starts rotating the rope counter-clockwise around the origin until it hits a pillar, at which point it is caught and starts rotating around that pillar counter-clockwise instead. The engine is then rotating at a smaller radius as some of the rope is caught between the origin and this pillar. This keeps going until the rope is too short to reach any other pillars.

Running these tests, buying all this infinitely thin rope and setting up these infinitely thin pillars, is expensive. Besides, the workers keep getting these nasty paper-like cuts from all these infinitely thin objects. It would be much more economical to just simulate the behaviour.

입력

The first line contains an integer nn, the number of pillars, and an integer dd, the length of the rope (1≤n≤1051 \leq n \leq 10^5, 1≤d≤1091 \leq d \leq 10^9).

The following nn lines each contain two integers x_ix\_i, y_iy\_i, the coordinates of the iith pillar (−109≤x_i,y_i≤109-10^9 \leq x\_i, y\_i \leq 10^9) for i∈1,2,…,ni \in 1, 2, \ldots, n. None of these pillars will lie on the rope.

출력

Print one line with an integer ii, meaning that the rope will end up spinning around the iith pillar in the input. Note that this index is 11-indexed. If the rope doesn't collide with any pillars i=−1i = -1. It is guaranteed that changing the input dd by at most ±10−6\pm 10^{-6} will not change ii.

예제1

  1. 예제 1

    입력
    5 200
    4 4
    4 -4
    3 1
    -4 4
    -4 -4
    
    예상 출력
    1