Sum of Vectors
Time limit0.5sMemory limit512 MB
Choose two of N vectors, each optionally sign-flipped per coordinate, to minimize the norm of their sum and output the pair with the chosen flips.
- Level
Hard8 of 10
- Topics
- Sorting, Geometry, Brute force, Math
- Solved
- No attempts yet
Problem
There are two-dimensional vectors. You can apply an operation that multiplies each coordinate by . For example, if , you can transform it into one of the following four forms.
- 1:
- 2:
- 3:
- 4:
Among the vectors, choose two vectors and and write a program that finds the minimum value of . Each of the two vectors may be transformed into one of the four forms above by applying the operation.
Input
The first line gives the number of vectors (). Each of the next lines gives the coordinates , of the -th vector (), one vector per line.
Output
On the first line, print four integers , , , separated by spaces. and are the indices of the chosen vectors, and , are the numbers of the operations applied. If several answers attain the minimum, print any one of them.
Hint
The sum of two vectors and is .
For a vector , is .