#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAXN (1000005)
int main() {
ios_base::sync_with_stdio(false);cin.tie(0);
ll N;
cin>>N;
pair<ll,ll> arr[N];
map<ll,ll> rowcnt, colcnt, row, col;
for(ll i = 0;i < N;i++){
cin>>arr[i].first>>arr[i].second;
rowcnt[arr[i].first]++;
colcnt[arr[i].second]++;
}
for(ll i = 0;i < N;i++){
row[arr[i].first] += (colcnt[arr[i].second] - 1);
col[arr[i].second] += (rowcnt[arr[i].first] - 1);
}
ll sum = 0;
for(ll i = 0;i < N;i++){
sum += (row[arr[i].first] - (colcnt[arr[i].second] - 1));
sum += (col[arr[i].second] - (rowcnt[arr[i].first] - 1));
}
cout<<sum / 2<<'\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
352 KB |
Output is correct |
7 |
Correct |
0 ms |
360 KB |
Output is correct |
8 |
Correct |
1 ms |
360 KB |
Output is correct |
9 |
Correct |
1 ms |
360 KB |
Output is correct |
10 |
Correct |
1 ms |
360 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
12 ms |
1880 KB |
Output is correct |
13 |
Correct |
9 ms |
2072 KB |
Output is correct |
14 |
Correct |
20 ms |
2920 KB |
Output is correct |
15 |
Correct |
307 ms |
11812 KB |
Output is correct |
16 |
Correct |
251 ms |
12372 KB |
Output is correct |
17 |
Correct |
221 ms |
11872 KB |
Output is correct |
18 |
Correct |
234 ms |
11872 KB |
Output is correct |
19 |
Correct |
795 ms |
18972 KB |
Output is correct |
20 |
Correct |
494 ms |
16124 KB |
Output is correct |
21 |
Correct |
826 ms |
19780 KB |
Output is correct |
22 |
Correct |
784 ms |
19668 KB |
Output is correct |