Skip to main content
Back to problems
Codeforces
Easy
Arrays
Geometry
Supercentral Point

Count how many points in a set have at least one point strictly above, below, to the left, and to the right of them.

Acceptance 0%
Also Available On
Other platform versions and source mappings for the same problem.
Problem Statement

Problem

You are given nn points on a 2D plane. A point is called supercentral if there exists at least one other point:

  • with the same xx coordinate and a larger yy coordinate,
  • with the same xx coordinate and a smaller yy coordinate,
  • with the same yy coordinate and a larger xx coordinate,
  • with the same yy coordinate and a smaller xx coordinate.

In other words, a supercentral point must have at least one point in each of the four cardinal directions: up, down, left, and right.

Your task is to determine how many points are supercentral.

Notes

  • A point does not count itself.
  • All points are distinct.
  • Points are considered only by exact coordinate equality on one axis and strict inequality on the other.

Input Format

  • The first line contains an integer nn.
  • Each of the next nn lines contains two integers xix_i and yiy_i, the coordinates of a point.

Output Format

Print a single integer — the number of supercentral points.

Constraints

  • 1n2001 \le n \le 200
  • Coordinates are integers and fit in 32-bit signed range.
  • All points are distinct.
Examples
Sample cases returned by the problem API.

Example 1

Input

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

Output

1

Explanation

Only point (0,0)(0,0) has a point to the left, right, above, and below it.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.