Problem: Link, Submission: 280673288
Code
signed main() {
ios::sync_with_stdio(0), cin.tie(0);
int n; cin >> n;
vector<vector<int>> g(2001);
vector<pair<int, int>> a(n);
for (int i = 0; i < n; i++) {
int u, v;
cin >> u >> v;
a[i].first = u + 1000;
a[i].second = v + 1000;
g[u + 1000].push_back(v + 1000);
g[v + 1000].push_back(u + 1000);
}
int ans = 0;
for (int i = 0; i < n; i++) {
int x = a[i].first;
int y = a[i].second;
bool l = 0, r = 0, u = 0, d = 0;
for (auto k : g[y]) {
if (k > x) {
r = 1;
} else if (k < x) {
l = 1;
}
}
for (auto k : g[x]) {
if (k > y) {
u = 1;
} else if (k < y) {
d = 1;
}
}
if (l == 1 and r == 1 and u == 1 and d == 1) {
ans += 1;
}
}
std::cout << ans << "\n";
return 0;
}