QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#22418. 좁은 곳을 싫어하는 소

Statistics

Farmer John은 $N$마리($2 \le N \le 2,000$)의 예민한 소를 얻었으며 번호는 $1$..$N$입니다. 소들은 다른 소와 너무 가까이 있는 것을 정말 싫어합니다. 아주 많이요.

FJ는 각 소 $i$의 정수 좌표 $X_{i}$, $Y_{i}$($1 \le X_{i} \le 100,000; 1 \le Y_{i} \le 100,000$)를 기록했습니다.

이 소들 중 정확히 두 마리가 서로 가장 가깝습니다. FJ는 그 둘을 조금 떨어뜨리고 싶습니다. 가장 가까운 두 소를 찾아 번호($i$)를 번호 순으로 출력하세요.

예로 다음 소들이 있는 들판을 생각해 봅시다(타자기 격자로 나타내어 가로세로 비율이 예상과 조금 다릅니다).

                    10 | . . . . . . . 3 . . . . .
                     9 | . 1 . . 2 . . . . . . . .
                     8 | . . . . . . . . . . . . .
                     7 | . . . . . . . . . . 4 . .
                     6 | . . . . . . 9 . . . . . .
                     5 | . 8 . . . . . . . . . . .
                     4 | . . . . . 7 . . . . . . .
                     3 | . . . . . . . . . 5 . . .
                     2 | . . . . . . . . . . . . .
                     1 | . . . . 6 . . . . . . . .
                     0 ---------------------------
                                           1 1 1 1
                       0 1 2 3 4 5 6 7 8 9 0 1 2 3

잠깐 살펴보면 소 $7$과 $9$가 가장 가깝다는 것을 알 수 있습니다(거리는 $\mathrm{sqrt}(1*1+2*2) = \mathrm{sqrt}(5)$). 따라서 한 줄에 7 9를 출력하면 됩니다(물론 따옴표는 제외합니다).

입력

  • 1번째 줄: 정수 $N$ 하나.

  • $2$..$N$+$1$번째 줄: $i$번째 줄은 소 $i$의 좌표를 공백으로 구분된 두 정수 $X_{i}$와 $Y_{i}$로 담습니다.

출력

  • 1번째 줄: 가장 가까운 두 소의 번호(정렬된 순서).

예제

입력 1

9
2 9
5 9
8 10
11 7
10 3
5 1
6 4
2 5
7 6

출력 1

7 9

참고

위의 예와 같습니다.

문제 작성: Rob Kolstad, 2009년

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.