#529
Bronze I
Comfortable Cows
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Farmer John's pasture can be regarded as a large 2D grid of square "cells" (picture a huge chessboard). Initially, the pasture is empty.

Farmer John will add NN (1N1051\le N\le 10^5) cows to the pasture one by one. The iith cow will occupy a cell (xi,yi)(x_i,y_i) that is distinct from the cells occupied by all other cows (0xi,yi10000\le x_i,y_i\le 1000).

A cow is said to be "comfortable" if it is horizontally or vertically adjacent to exactly three other cows. Farmer John is interested in counting the comfortable cows on his farm. For each ii in the range 1N1 \ldots N, output the total number of comfortable cows after the iith cow is added to the pasture.

입력

The first line contains a single integer NN. Each of the next NN lines contains two space-separated integers, indicating the (x,y)(x,y) coordinates of a cow's cell. It is guaranteed that all these cells are distinct.

출력

The iith line of output should contain the total number of comfortable cows after the first ii cows are added to the pasture.

예제 입력 1

8
0 1
1 0
1 1
1 2
2 1
2 2
3 1
3 2

예제 출력 1

0
0
0
1
0
0
1
2

점수

Test cases 1-4 satisfy N400N\le 400.Test cases 5-12 satisfy no additional constraints.

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Bronze I1명 투표· 약 1개월 전
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.