#include <bits/stdc++.h>
#define N 400009
#define ff first
#define ss second
#define pb push_back
#define ll long long
#define pii pair <ll, ll>
using namespace std;
ll n, ans;
map<ll, int>a, b;
pii p[N];
int main(){
cin>>n;
for(int i=1; i<=n; i++)
cin>>p[i].ff>>p[i].ss, a[p[i].ff]++, b[p[i].ss]++;
for(int i=1; i<=n; i++){
ans+=min(a[p[i].ff]-1, b[p[i].ss]-1);
}
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Incorrect |
2 ms |
252 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |