#include <bits/stdc++.h>
#define ll long long
using namespace std;
void answer() {
int n;
cin >> n;
vector<pair<int, int>> v;
map<int, int> mpx, mpy;
int x, y;
for(int i=1; i<=n;i++){
cin >> x>> y;
v.push_back({x, y});
mpx[x]++;
mpy[y]++;
}
ll ans=0;
for(int i=0; i<n; i++){
// cout << mpx[v[i].first] << ' ' << mpy[v[i].second] << ' ';
ans += (mpx[v[i].first] - 1) * (mpy[v[i].second]-1);
}
cout << ans;
}
int main() {
int t=1;
// cin >> t;
while(t--) {
answer();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
296 KB |
Output is correct |
5 |
Correct |
1 ms |
300 KB |
Output is correct |
6 |
Correct |
0 ms |
296 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
316 KB |
Output is correct |
12 |
Correct |
10 ms |
952 KB |
Output is correct |
13 |
Correct |
11 ms |
980 KB |
Output is correct |
14 |
Correct |
14 ms |
1364 KB |
Output is correct |
15 |
Correct |
155 ms |
6048 KB |
Output is correct |
16 |
Correct |
165 ms |
6436 KB |
Output is correct |
17 |
Correct |
152 ms |
6080 KB |
Output is correct |
18 |
Correct |
156 ms |
6112 KB |
Output is correct |
19 |
Correct |
434 ms |
13240 KB |
Output is correct |
20 |
Correct |
308 ms |
9140 KB |
Output is correct |
21 |
Correct |
458 ms |
13360 KB |
Output is correct |
22 |
Correct |
454 ms |
13292 KB |
Output is correct |