#include <bits/stdc++.h>
using namespace std;
#define sz(x) int(x.size())
#define all(x) begin(x), end(x)
using ll = long long;
int compress(vector<int> &v) {
vector<int> vals(all(v));
sort(all(vals));
vals.erase(unique(all(vals)), end(vals));
for (int &x : v) x = int(lower_bound(all(vals), x) - begin(vals));
return sz(vals);
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n;
cin >> n;
vector<int> x(n), y(n);
for (int i = 0; i < n; i++) {
cin >> x[i] >> y[i];
}
int cantX = compress(x), cantY = compress(y);
vector<int> freqX(cantX, 0), freqY(cantY, 0);
for (int i = 0; i < n; i++) {
freqX[x[i]]++, freqY[y[i]]++;
}
ll ans = 0;
for (int i = 0; i < n; i++) {
ans += (freqX[x[i]] - 1LL) * (freqY[y[i]] - 1LL);
}
cout << ans << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
544 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
4 ms |
604 KB |
Output is correct |
13 |
Correct |
4 ms |
648 KB |
Output is correct |
14 |
Correct |
4 ms |
600 KB |
Output is correct |
15 |
Correct |
52 ms |
3780 KB |
Output is correct |
16 |
Correct |
57 ms |
4008 KB |
Output is correct |
17 |
Correct |
47 ms |
3776 KB |
Output is correct |
18 |
Correct |
49 ms |
4032 KB |
Output is correct |
19 |
Correct |
134 ms |
9552 KB |
Output is correct |
20 |
Correct |
103 ms |
7008 KB |
Output is correct |
21 |
Correct |
141 ms |
10432 KB |
Output is correct |
22 |
Correct |
154 ms |
10396 KB |
Output is correct |