#include<bits/stdc++.h>
using namespace std;
map<int, int> cntx, cnty;
int main(){
int n;
cin >> n;
vector<pair<int, int>> stars;
for(int i = 0; i < n; i++){
int x1, y1;
cin >> x1 >> y1;
stars.push_back({x1, y1});
cntx[x1]++, cnty[y1]++;
}
long long ans = 0;
for(pair<int, int> st : stars){
int x = st.first, y = st.second;
ans += (cntx[x] - 1) * (cnty[y] - 1);
}
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
464 KB |
Output is correct |
8 |
Correct |
13 ms |
376 KB |
Output is correct |
9 |
Correct |
3 ms |
376 KB |
Output is correct |
10 |
Correct |
3 ms |
380 KB |
Output is correct |
11 |
Correct |
4 ms |
376 KB |
Output is correct |
12 |
Correct |
20 ms |
1016 KB |
Output is correct |
13 |
Correct |
24 ms |
1016 KB |
Output is correct |
14 |
Correct |
29 ms |
1400 KB |
Output is correct |
15 |
Correct |
306 ms |
6380 KB |
Output is correct |
16 |
Correct |
338 ms |
6640 KB |
Output is correct |
17 |
Correct |
305 ms |
6256 KB |
Output is correct |
18 |
Correct |
310 ms |
6248 KB |
Output is correct |
19 |
Correct |
848 ms |
13580 KB |
Output is correct |
20 |
Correct |
600 ms |
9444 KB |
Output is correct |
21 |
Correct |
900 ms |
13472 KB |
Output is correct |
22 |
Correct |
1063 ms |
13472 KB |
Output is correct |