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.