AmazonOA #313
Count Idle Warehouse Robots
估计中等可在线判题
n robots stand at distinct integer coordinates. A robot is idle if another robot is to its left and another to its right in the same row, and another is above it and another below it in the same column. These robots do not need to be at distance 1, and there may be gaps in between. Find the number of idle robots.
输入格式
The first line contains n, followed by n lines of x y. The original bounds are 1≤n≤100000, −10^9≤x,y≤10^9, and the coordinate pairs are distinct.
输出格式
Output a single integer, the answer.
样例 1
输入:
5
0 0
-2 0
2 0
0 -3
0 3
输出:
1
样例 2
输入:
3
0 0
1 0
2 0
输出:
0
样例 3
输入:
4
0 0
1 0
0 1
1 1
输出:
0
样例说明
The answers are 1, 0 and 0. In the first example no neighbor needs to be at distance 1, and the center robot is still idle.