logo AlgoBeat OnlineJudge
登录 注册

#214977. [ICPC 2021 Yokohama R] The Cross Covers Everything

内存限制:1024 MiB 时间限制:3000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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

:::align{center}

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 points with coordinates () are given, the ordered pair is said to cover a point if , , or both hold. Your task is to find how many pairs cover all the points. No two given points have the same -coordinate nor the same -coordinate.

输入格式

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

The first line contains an integer (), which is the number of points given. Two integers and in the -th line of the following lines are the coordinates of the -th point (, ). You may assume that and hold for all .

输出格式

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.

Amendment

The conditions , and , have to be added to be satisfied for the ordered pair that are counted. This was announced during the contest.