PivotOJ

Comfortable Cows

시간 제한: 1000ms메모리 제한: 512MB출처: USACO 2021 February BronzeBOJ 21236

문제

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
출력
0
0
0
1
0
0
1
2
코드를 제출하려면 로그인하세요.