아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Treehouse

시간 제한3초메모리 제한1024 MB

요약
서로 다른 나무 N개의 좌표가 주어질 때, 네 꼭짓점이 모두 나무인 정사각형의 개수를 센다.
난이도

보통10점 중 6점

유형
기하, 해시맵, 완전 탐색
정답자
아직 제출이 없습니다

문제

Pusheen wants to build a treehouse in the Treehouse forest in Brunnshög in the north of Lund. The treehouse should to be built on a square platform in the treetops, with a tree in each of the four corners. When Pusheen has picked a spot to built the treehouse, trees that are located between the corners will be cut down. Pusheen has a 2D map with all the (x, y)-coordinates of the trees in the forest. In how many places can they build a square treehouse?

입력

The first line has an integer 4≤N≤2,0004 \leq N \leq 2\\, 000 , the number of trees in the forest. Each of the following NN lines has two integers −10,000≤x_i,y_i≤10,000-10,000\leq x\_i, y\_i \leq 10,000, the x- and y-coordinates of tree ii. All points are distinct.

출력

An integer, the number of suitable spots for a tree house.

힌트

Illustration of the two possible treehouse locations in sample 1.

예제1

  1. 예제 1

    입력
    9
    1 5
    1 7
    3 1
    3 5
    3 7
    5 7
    6 2
    7 3
    7 6
    
    예상 출력
    2