Friends and Berries - 2
시간 제한2초메모리 제한256 MB
좌표가 서로 다른 n개의 점이 주어질 때, 임의의 세 번째 점 w에 대해서도 두 점 u, v의 거리 제곱이 삼각형의 친밀도보다 크거나 같은 모든 쌍을 찾는다.
문제
There is a group of children. According to a proverb, every man to his own taste. So the children value strawberries and raspberries differently. Let us say that -th child rates his attachment to strawberry as and his attachment to raspberry as .
According to another proverb, opposites attract. Surprisingly, those children become friends whose tastes differ.
Let us define friendliness between two children and as
The friendliness between three children , , is half the sum of pairwise friendlinesses:
The best friends are such pairs of children that and for every . Your goal is to find all pairs of best friends.
입력
In the first line there is one integer , the number of children ().
Each of the next lines contains two integers and ().
It is guaranteed that, for every two children, their tastes differ. In other words, if , then or .
출력
On the first line, output the number of pairs of best friends.
After that, output those pairs. Each pair should be printed on a separate line. A pair is denoted by two integers: the indices of children in this pair. Children are numbered in the order of input starting from . You can output pairs in any order. You can output indices in each pair in any order.
It is guaranteed that the required number of pairs doesn't exceed .