ENG  RUSTimus Online Judge
Online Judge
Online contests
About Online Judge
Frequently asked questions
Site news
Problem set
Submit solution
Judge status
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests

Ural Regional School Programming Contest 2015

About     Problems     Submit solution     Judge status     Standings
Contest is over

F. Friends and Berries

Time limit: 2.0 second
Memory limit: 64 MB
There is a group of n children. According to a proverb, every man to his own taste. So the children value strawberries and raspberries differently. Let’s say that i-th child rates his attachment to strawberry as si and his attachment to raspberry as ri.
According to another proverb, opposites attract. Surprisingly, those children become friends whose tastes differ.
Let’s define friendliness between two children v, u as: p(v, u) = sqrt((svsu)2 + (rvru)2)
The friendliness between three children v, u, w is the half the sum of pairwise friendlinesses: p(v,u,w) = (p(v,u) + p(v,w) + p(u,w)) / 2
The best friends are that pair of children v, u for which vu and p(v, u) ≥ p(v,u,w) for every child w. Your goal is to find all pairs of the best friends.


In the first line there is one integer n — the amount of children (2 ≤ n ≤ 2 · 105).
In the next n lines there are two integers in each line — si and ri (−108si, ri ≤ 108).
It is guaranteed that for every two children their tastes differ. In other words, if vu then svsu or rvru.


Output the number of pairs of best friends in the first line.
Then output those pairs. Each pair should be printed on a separate line. One pair is two numbers — the indices of children in this pair. Children are numbered in the order of input starting from 1. You can output pairs in any order. You can output indices of the pair in any order.
It is guaranteed that the amount of pairs doesn’t exceed 105.


2 3
7 6
1 2
5 5
2 -4
-4 2
Problem Author: Alexey Danilyuk (prepared by Alexey Danilyuk, Alexander Borzunov)
Problem Source: Ural Regional School Programming Contest 2015
To submit the solution for this problem go to the Problem set: 2067. Friends and Berries