Lonesome Partners

Interview

Time limit1sMemory limit128 MB

Summary
Given N points, find the 1-based indices of the two points with the largest Euclidean distance, guaranteed unique.
Level

Easy3 of 10

Topics
Brute force, Geometry, Implementation, Array
Solved
No attempts yet

Problem

Bessie and the rest of the herd — NN cows in total (2≤N≤5002 \le N \le 500) — have gone to a dance. During one part of the dance, two cows are chosen as the Belles of the Ball.

The organizer records the integer coordinates Xi,YiX_i, Y_i (0≤Xi≤50000 \le X_i \le 5000, 0≤Yi≤50000 \le Y_i \le 5000) of every cow on the floor and asks you to find the indices of the two cows that are farthest apart. This farthest pair is guaranteed to be unique.

Distance is the ordinary Euclidean distance — the square root of the sum of the squares of the differences of the XX and YY coordinates:

d=(Xa−Xb)2+(Ya−Yb)2d = \sqrt{(X_a - X_b)^2 + (Y_a - Y_b)^2}

For example, consider these eight cows placed on the floor (C marks a cow):

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

Here the two cows that are farthest apart are the one at (2,8)(2, 8) and the one at (9,1)(9, 1).

Input

  • Line 1: a single integer NN.
  • Lines 2 to N+1N+1: line i+1i+1 contains two integers XiX_i and YiY_i, the coordinates of cow ii.

Output

  • One line with two integers: the 1-based indices of the two cows that are farthest apart, printed in increasing order and separated by a single space.

Hint

In the illustrated example the farthest-apart pair is cow 33 (at (2,8)(2, 8)) and cow 77 (at (9,1)(9, 1)), so their indices are printed as 3 7.

Examples1

  1. Example 1

    Input
    8
    2 6
    3 3
    2 8
    4 5
    7 5
    5 5
    9 1
    5 4
    
    Expected output
    3 7