#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main() {
cin.tie(0); ios::sync_with_stdio(false);
int n;
long long ans = 0;
cin >> n;
map<int, vector<int>> adjX;
map<int, vector<int>> adjY;
for (int i = 0, xi, yi; i < n; i++) {
cin >> xi >> yi;
adjX[xi].push_back(yi);
adjY[yi].push_back(xi);
}
int numX;
for (auto &[xi, adj] : adjX) {
numX = adj.size() - 1;
for (auto &yi : adj) {
if (!adjY.count(yi)) continue;
ans += numX * (adjY[yi].size() - 1);
}
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
460 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
6 ms |
1616 KB |
Output is correct |
13 |
Correct |
5 ms |
1628 KB |
Output is correct |
14 |
Correct |
9 ms |
2396 KB |
Output is correct |
15 |
Correct |
90 ms |
9196 KB |
Output is correct |
16 |
Correct |
107 ms |
9576 KB |
Output is correct |
17 |
Correct |
95 ms |
9236 KB |
Output is correct |
18 |
Correct |
97 ms |
9044 KB |
Output is correct |
19 |
Correct |
258 ms |
14636 KB |
Output is correct |
20 |
Correct |
178 ms |
12368 KB |
Output is correct |
21 |
Correct |
258 ms |
15444 KB |
Output is correct |
22 |
Correct |
285 ms |
15448 KB |
Output is correct |