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 רשם את הקואורדינטות השלמות $X_{i}$, $Y_{i}$ של כל פרה $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.