#SRD0000118. Sereja và những hình vuông (Sereja and Squares)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Sereja và những hình vuông (Sereja and Squares)
Sereja and Squares
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Sereja has drawn distinct points in the plane, each with integer coordinates .
Count the axis-aligned squares whose four vertices belong to the given point set. Each square must have positive side length and is counted exactly once, regardless of the order in which its vertices are listed.
Squares with rotated (non-axis-aligned) sides must not be counted.
Input
- The first line contains the integer .
- Each of the next lines contains the coordinates of a point.
- All points are distinct.
Output
Print one integer: the number of squares with sides parallel to the coordinate axes.
Subtasks
-
Subtask 1 (10 points): ; ; all points are distinct.
-
Subtask 2 (20 points): ; ; all points are distinct.
-
Subtask 3 (30 points): ; ; all points are distinct.
-
Subtask 4 (40 points): ; ; all points are distinct.
Examples
Example 1
Input
5
0 0
0 2
2 0
2 2
1 1
Output
1
Explanation
The four points form one square of side length . Point contributes no further axis-aligned square.
Example 2
Input
9
0 0
1 1
2 2
0 1
1 0
0 2
2 0
1 2
2 1
Output
5
Explanation
The full grid has four squares of side 1 and one square of side 2, totaling 5.