#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define AC ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fs first
#define sc second
#define pb push_back
int N;
map<int, int> cntx, cnty;
ll ans;
int main() {
AC
cin >> N ;
int x[N], y[N];
for(int i=0; i<N; i++){
cin >> x[i] >> y[i];
cntx[x[i]]++, cnty[y[i]]++;
}
for(int i=0; i<N; i++){
ans += (ll)(cntx[x[i]]-1)*(ll)(cnty[y[i]]-1);
}
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 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 |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
5 ms |
860 KB |
Output is correct |
13 |
Correct |
5 ms |
856 KB |
Output is correct |
14 |
Correct |
11 ms |
1180 KB |
Output is correct |
15 |
Correct |
81 ms |
4140 KB |
Output is correct |
16 |
Correct |
89 ms |
4204 KB |
Output is correct |
17 |
Correct |
81 ms |
4140 KB |
Output is correct |
18 |
Correct |
80 ms |
3932 KB |
Output is correct |
19 |
Correct |
223 ms |
5460 KB |
Output is correct |
20 |
Correct |
163 ms |
5068 KB |
Output is correct |
21 |
Correct |
231 ms |
5748 KB |
Output is correct |
22 |
Correct |
236 ms |
5852 KB |
Output is correct |