LCC '24 Contest 3 J2 - Squares

View as PDF

Submit solution

Points: 3 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

After thoroughly examining each iceberg, Bob the penguin has made a second revelation: some of the icebergs are in fact squares! This time, he has given you a list of N icebergs, each with coordinates (x_1,y_1), (x_2,y_2), (x_3,y_3), (x_4,y_4), in clockwise order of vertices, starting from the top left. He would like to know how many of these icebergs are in the shape of a square (4 sides of equal length). Keep in mind that the entire iceberg needs to be a square to count, rather than the portion above the x-axis.

Input Specification

The first line will contain the integer N, representing the number of icebergs.

There will be N groups of 4 lines, representing the coordinates of the icebergs, where each group of 4 being the coordinates of a single iceberg with points x_i, y_i.

Output Specification

Output one integer, representing the number of icebergs that are in the shape of square.

Constraints

For all test cases,

1 \leq N \leq 5 \times 10^4

-10^3 \leq x_i,y_i \leq 10^3

Sample Input

2
-3 2
7 2
7 -6
-3 -6
-1 1
1 1
1 -1
-1 -1

Sample Output

1

Sample Explanation

The first iceberg is in the shape of a rectangle, while the second is in the shape of a square.


Comments

There are no comments at the moment.