302218: CF425D. Sereja and Squares

Memory Limit:512 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Sereja and Squares

题意翻译

平面直角坐标系上有 $n$ 个互不相同的点,求有多少个边与坐标轴平行的正方形,其四个顶点均在这 $n$ 个点中。

题目描述

Sereja has painted $ n $ distinct points on the plane. The coordinates of each point are integers. Now he is wondering: how many squares are there with sides parallel to the coordinate axes and with points painted in all its four vertexes? Help him, calculate this number.

输入输出格式

输入格式


The first line contains integer $ n $ $ (1<=n<=10^{5}) $ . Each of the next $ n $ lines contains two integers $ x_{i},y_{i} $ $ (0<=x_{i},y_{i}<=10^{5}) $ , the integers represent the coordinates of the $ i $ -th point. It is guaranteed that all the given points are distinct.

输出格式


In a single line print the required number of squares.

输入输出样例

输入样例 #1

5
0 0
0 2
2 0
2 2
1 1

输出样例 #1

1

输入样例 #2

9
0 0
1 1
2 2
0 1
1 0
0 2
2 0
1 2
2 1

输出样例 #2

5

Input

题意翻译

平面直角坐标系上有 $n$ 个互不相同的点,求有多少个边与坐标轴平行的正方形,其四个顶点均在这 $n$ 个点中。

加入题单

上一题 下一题 算法标签: