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

30814번 - Watchmen 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB22181578.947%

문제

Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg should warn them as soon as possible. There are $n$ watchmen on a plane, the $i$-th watchman is located at point $(x_i, y_i)$.

They need to arrange a plan, but there are some difficulties on their way. As you know, Doctor Manhattan considers the distance between watchmen $i$ and $j$ to be $|x_i - x_j| + |y_i - y_j|$. Daniel, as an ordinary person, calculates the distance using the formula $\sqrt{(x_i - x_j)^2 + (y_i - y_j)^2}$.

The success of the operation relies on the number of pairs $(i, j)$ (1ドル \leq i < j \leq n$), such that the distance between watchman $i$ and watchmen $j$ calculated by Doctor Manhattan is equal to the distance between them calculated by Daniel. You were asked to compute the number of such pairs.

입력

The first line of the input contains the single integer $n$ (1ドル \leq n \leq 200,000円$) --- the number of watchmen.

Each of the following $n$ lines contains two integers $x_i$ and $y_i$ ($|x_i|, |y_i| \leq 10^9$).

출력

Print the number of pairs of watchmen such that the distance between them calculated by Doctor Manhattan is equal to the distance calculated by Daniel.

제한

예제 입력 1

3
1 1
7 5
1 5

예제 출력 1

2

예제 입력 2

6
0 0
0 1
0 2
-1 1
0 1
1 1

예제 출력 2

11

노트

In the first sample, the distance between watchman 1ドル$ and watchman 2ドル$ is equal to $|1 - 7| + |1 - 5| = 10$ for Doctor Manhattan and $\sqrt{(1 - 7)^2 + (1 - 5)^2} = 2 \cdot \sqrt{13}$ for Daniel. For pairs $(1, 1),ドル $(1, 5)$ and $(7, 5),ドル $(1, 5)$ Doctor Manhattan and Daniel will calculate the same distances.

출처

Olympiad > Moscow Open Olympiad in Informatics > Moscow Open Olympiad in Informatics 2015-16 > Day 1 Echidna번

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

출처

대학교 대회

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

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