#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<pair<int, int>> p;
int main(){
int n; cin >> n;
p.resize(n);
for(int i = 0; i < n; i++) {
int x, y; cin >> x >> y;
p[i].first = x; p[i].second = y;
}
std::map<int, int> horizontal, vertical;
for (auto const & x : p)
{
horizontal[x.first]++;
vertical[x.second]++;
}
int ans = 0;
for(int i = 0; i < n; i++) {
int h = horizontal[p[i].first]-1;
int v = vertical[p[i].second]-1;
if(h > 0 && v > 0){
horizontal[p[i].first]--;
vertical[p[i].second]--;
ans++;
}
}
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
428 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |