cswork / OA打开练习工作台

AmazonOA #42

Get Number Idle Robots

估计简单可在线判题

考点(AI 标注)哈希计数

A robot is idle if and only if at least one other robot lies strictly to its left and one strictly to its right in the same row, and one strictly above and one strictly below it in the same column. They do not need to be adjacent. Find the number of idle robots.

输入格式

The first line contains n (1..100000), followed by n lines of x y (−10⁹..10⁹). Robots at the same coordinates are counted separately, but they are not strict directional neighbors of each other.

输出格式

Output a single integer answer.

样例 1

输入:

9
0 0
1 0
2 0
0 1
1 1
2 1
0 2
1 2
2 2

输出:

1

样例 2

输入:

1
0 0

输出:

0

样例 3

输入:

5
0 0
-1 0
1 0
0 -1
0 1

输出:

1

样例说明

Example 1: in a 3×3 grid of points, only the center (1,1) has neighbors in all four directions, so the answer is 1. Example 2: there are no neighbors, so the answer is 0. Example 3: the center (0,0) of the cross is idle, while each of the other four points lacks a direction, so the answer is 1.