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

24966번 - The Cross Covers Everything 다국어

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

문제

A cross-shaped infinite area on the $x$-$y$ plane can be specified by two distinct points as depicted on the figure below.

Figure J.1. The cross area specified by two points numbered 2ドル$ and 4ドル$

Given a set of points on the plane, you are asked to figure out how many pairs of the points form a cross-shaped area that covers all the points. To be more precise, when $n$ points with coordinates $(x_i , y_i$) ($i = 1, \dots , n$) are given, the ordered pair $<p, q>$ is said to cover a point $(x, y)$ if $x_p ≤ x ≤ x_q,ドル $y_p ≤ y ≤ y_q,ドル or both hold. Your task is to find how many pairs $<p, q>$ cover all the $n$ points. No two given points have the same $x$-coordinate nor the same $y$-coordinate.

입력

The input consists of a single test case of the following format.

$\begin{align*}& n \\ & x_1 ,円 y_1 \\ & \vdots \\ & x_n ,円 y_n\end{align*}$

The first line contains an integer $n$ (2ドル ≤ n ≤ 2 × 10^5$), which is the number of points given. Two integers $x_i$ and $y_i$ in the $i$-th line of the following $n$ lines are the coordinates of the $i$-th point (1ドル ≤ x_i ≤ 10^6,ドル 1ドル ≤ y_i ≤ 10^6$). You may assume that $x_j \ne x_k$ and $y_j \ne y_k$ hold for all $j \ne k$.

출력

Print in a line the number of ordered pairs of points that satisfy the condition.

제한

예제 입력 1

4
2 1
1 2
6 3
5 4

예제 출력 1

4

예제 입력 2

20
15 9
14 13
2 7
10 5
11 17
13 8
9 3
8 12
6 4
19 18
12 1
3 2
5 10
18 11
4 19
20 16
16 15
1 14
7 6
17 20

예제 출력 2

9

힌트

Figure J.1 depicts the cross specified by two points numbered 2 and 4, that are the second and the fourth points of the Sample Input 1. This is one of the crosses covering all the points.

출처

ICPC > Regionals > Asia Pacific > Japan > ICPC 2021 Asia Yokohama Regional J번

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

출처

대학교 대회

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

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