#include "bits/stdc++.h"
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size
#define fr front
#define bc backn
#define pii pair<int,int>
#define all(x) x.begin() , x.end()
#define cmin(a, b) a = min(a , b)
#define cmax(a, b) a = max(a, b)
#define mems(arr , a) memset(arr , a , sizeof arr)
#define each(i , arr) for(auto &i : arr)
const int MOD = 1e9 + 7;
const int INF = 1e18;
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
t = 1;
// cin >> t;
while(t--){
int n; cin >> n;
int x[n] , y[n];
map<int , int> cntx , cnty;
for(int i = 0; i < n; i++){
cin >> x[i] >> y[i];
cntx[x[i]]++ , cnty[y[i]]++;
}
int ans = 0;
for(int i = 0; i < n; i++){
ans += (cntx[x[i]]-1) * (cnty[y[i]]-1);
}
cout << ans << '\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
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 |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
5 ms |
1372 KB |
Output is correct |
13 |
Correct |
5 ms |
1368 KB |
Output is correct |
14 |
Correct |
8 ms |
1880 KB |
Output is correct |
15 |
Correct |
86 ms |
7252 KB |
Output is correct |
16 |
Correct |
92 ms |
7888 KB |
Output is correct |
17 |
Correct |
85 ms |
7312 KB |
Output is correct |
18 |
Correct |
85 ms |
7252 KB |
Output is correct |
19 |
Correct |
242 ms |
12124 KB |
Output is correct |
20 |
Correct |
172 ms |
10216 KB |
Output is correct |
21 |
Correct |
251 ms |
12908 KB |
Output is correct |
22 |
Correct |
254 ms |
13068 KB |
Output is correct |