Logo
(追記) (追記ここまで)

3637번 - Inner Vertices 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 64 MB268861.538%

문제

There is an infinite square grid. Some vertices of the grid are black and other vertices are white.

A vertex $V$ is called inner if it is both vertical-inner and horizontal-inner. A vertex $V$ is called horizontal-inner if there are two such black vertices in the same row that $V$ is located between them. A vertex $V$ is called vertical-inner if there are two such black vertices in the same column that $V$ is located between them.

On each step all white inner vertices became black while the other vertices preserve their colors. The process stops when all the inner vertices are black.

Write a program that calculates a number of black vertices after the process stops.

입력

The first line of the input file contains one integer number $n$ (0ドル \le n \le 100,000円$) --- number of black vertices at the beginning.

The following $n$ lines contain two integer numbers each --- the coordinates of different black vertices. The coordinates do not exceed 10ドル^9$ by their absolute values.

출력

Output the number of black vertices when the process stops. If the process does not stop, output -1.

제한

예제 입력 1

4
0 2
2 0
-2 0
0 -2

예제 출력 1

5

힌트

출처

ICPC > Regionals > Northern Eurasia > Northwestern Russia Regional Contest > NEERC Northern Subregional 2005 I번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /