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

30298번 - Good Triangle 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 1024 MB68353350.769%

문제

You are given $n$ distinct points on the two dimensional plane.

We define the distance between two points $P=(x_1, y_1)$ and $Q=(x_2, y_2)$ as $d(P, Q)=|x_1-x_2|+|y_1-y_2|$.

Let's say that three distinct points $U, V, W$ form a good triangle if there exists a point $T$ such that $d(U, T)=d(V, T)=d(W, T)$. Note that $T$ does not have to be a lattice point.

Find the number of good triangles that can be formed by the given points.

입력

The first line of input contains $N$.

The $i$-th line of the next $N$ lines contains two space-separated integers $x_i, y_i,ドル meaning that the coordinate of the $i$-th point is $(x_i, y_i)$.

출력

Print one integer, the number of good triangles that can be formed by the given points.

제한

  • 3ドル \leq N \leq 500,000円$
  • $-10^9 \leq x_i, y_i \leq 10^9$ (1ドル \leq i \leq N$)
  • $(x_i, y_i) \neq (x_j, y_j)$ if $i\ne j$ (1ドル \leq i, j \leq N$)
  • All values in the input are integers.

예제 입력 1

5
1 -1
1 5
5 7
1 3
4 2

예제 출력 1

9

예제 입력 2

10
-2 -1
-2 2
-1 -2
-1 -1
-1 1
0 1
1 -1
1 2
2 -1
2 1

예제 출력 2

108

힌트

출처

University > KAIST > KAIST ICPC Mock Competition > 2023 KAIST 13th ICPC Mock Competition G번

Camp > Petrozavodsk Programming Camp > Summer 2024 > Day 2: K-ontest G번

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

출처

대학교 대회

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

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