#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pii pair<int, int>
#define fi first
#define se second
#define __builtin_popcount __builtin_popcountll
#define all(x) (x).begin(), (x).end()
#define debug(a, l, r) for (int i = (l); i <= (r); ++i) cout << (a)[i] << ' '; cout << '\n';
const int MAXN = 3e5 + 5;
int n, x[MAXN], y[MAXN];
map<int, int> cntx, cnty;
map<pii, int> cnt;
signed main() {
#ifdef NCTHANH
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(0);
cin.tie(nullptr); cout.tie(nullptr);
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> x[i] >> y[i];
cntx[x[i]]++;
cnty[y[i]]++;
cnt[{x[i], y[i]}]++;
}
int res = 0;
for (int i = 1; i <= n; ++i) {
int cx = cntx[x[i]] - cnt[{x[i], y[i]}];
int cy = cnty[y[i]] - cnt[{x[i], y[i]}];
res += cx * cy;
}
cout << res;
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |