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.