#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
int n;
cin>>n;
unordered_map<int, int> cntx, cnty;
pair<int, int> stars[n];
for (int i = 0; i < n; i++) {
int x, y;
cin>>x>>y;
stars[i] = {x, y};
cntx[x]++;
cnty[y]++;
}
ll total = 0;
for (int i = 0; i < n; i++) {
int x = stars[i].first;
int y = stars[i].second;
total += (cntx[x]-1) * (cnty[y]-1);
}
cout<<total<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
0 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
6 ms |
848 KB |
Output is correct |
13 |
Correct |
8 ms |
848 KB |
Output is correct |
14 |
Correct |
8 ms |
1160 KB |
Output is correct |
15 |
Correct |
87 ms |
3588 KB |
Output is correct |
16 |
Correct |
70 ms |
3764 KB |
Output is correct |
17 |
Correct |
64 ms |
3584 KB |
Output is correct |
18 |
Correct |
66 ms |
3584 KB |
Output is correct |
19 |
Correct |
173 ms |
5176 KB |
Output is correct |
20 |
Correct |
139 ms |
4672 KB |
Output is correct |
21 |
Correct |
206 ms |
5376 KB |
Output is correct |
22 |
Correct |
190 ms |
5376 KB |
Output is correct |