Logo
(追記) (追記ここまで)

19503번 - Friends and Berries - 2 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 256 MB422100.000%

문제

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 us say that $i$-th child rates his attachment to strawberry as $s_{i}$ and his attachment to raspberry as $r_{i}$.

According to another proverb, opposites attract. Surprisingly, those children become friends whose tastes differ.

Let us define friendliness between two children $v$ and $u$ as $$p(u, v) = (s_{u} - s_{v})^{2} + (r_{u} - r_{v})^{2}\text{.}$$

The friendliness between three children $v,ドル $u,ドル $w$ is half the sum of pairwise friendlinesses: $$p(u, v, w) = \frac{p(u, v) + p(u, w) + p(v, w)}{2}\text{.}$$

The best friends are such pairs of children $(u, v)$ that $u \ne v$ and $p(u, v) \ge p(u, v, w)$ for every $w$. Your goal is to find all pairs of best friends.

입력

In the first line there is one integer $n,ドル the number of children (2ドル \le n \le 2 \cdot 10^{5}$).

Each of the next $n$ lines contains two integers $s_{i}$ and $r_{i}$ ($-10^{8} \le s_{i}, r_{i} \le 10^{8}$).

It is guaranteed that, for every two children, their tastes differ. In other words, if $u \ne v,ドル then $s_{u} \ne s_{v}$ or $r_{u} \ne r_{v}$.

출력

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 1ドル$. 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 10ドル^{6}$.

제한

예제 입력 1

4
0 0
1 0
0 1
1 1

예제 출력 1

2
1 4
2 3

예제 입력 2

3
0 0
0 10
5 8

예제 출력 2

0

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2016 > Day 7: Ural FU Dandelion Contest I번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /