CF425D.Sereja and Squares

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

Sereja 在平面上画了 nn 个互不相同的点,每个点的坐标均为整数。现在他想知道:有多少个边与坐标轴平行的正方形,其四个顶点上均画有点?请帮助他计算这个数目。

输入格式

The first line contains integer n (1 ≤ n ≤ 105). Each of the next n lines contains two integers x__i, y__i (0 ≤ x__i, y__i ≤ 105), the integers represent the coordinates of the i-th point. It is guaranteed that all the given points are distinct.

第一行包含一个整数 nn(1≤n≤1051 \leq n \leq 10^5)。接下来的 nn 行中,每行包含两个整数 xix_i、yiy_i(0≤xi,yi≤1050 \leq x_i, y_i \leq 10^5),表示第 ii 个点的坐标。保证所有给定的点互不相同。

输出格式

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

输入解题思路,AI测评打分。不知道怎么写?

首页