#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
const ll mod = 998244353;
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define faster ios::sync_with_stdio(false);cin.tie(nullptr)
int main() {
ll N;
cin >> N;
vector<ll> X(N),Y(N);
rep(i,N) cin >> X[i] >> Y[i];
vector<ll> x=X,y=Y;
sort(all(x));
x.erase(unique(all(x)),x.end());
sort(all(y));
y.erase(unique(all(y)),y.end());
rep(i,N) X[i]=lower_bound(all(x),X[i])-x.begin();
rep(i,N) Y[i]=lower_bound(all(y),Y[i])-y.begin();
vector<ll> cntX(300500,0),cntY(300500,0);
rep(i,N) cntX[X[i]]++;
rep(i,N) cntY[Y[i]]++;
ll ans=0;
rep(i,N){
ans+=(cntX[X[i]]-1)*(cntY[Y[i]]-1);
}
cout << ans << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4956 KB |
Output is correct |
2 |
Correct |
2 ms |
4952 KB |
Output is correct |
3 |
Correct |
2 ms |
4952 KB |
Output is correct |
4 |
Correct |
2 ms |
5152 KB |
Output is correct |
5 |
Correct |
2 ms |
4952 KB |
Output is correct |
6 |
Correct |
2 ms |
4952 KB |
Output is correct |
7 |
Correct |
2 ms |
4956 KB |
Output is correct |
8 |
Correct |
2 ms |
4952 KB |
Output is correct |
9 |
Correct |
3 ms |
4952 KB |
Output is correct |
10 |
Correct |
2 ms |
4952 KB |
Output is correct |
11 |
Correct |
2 ms |
4956 KB |
Output is correct |
12 |
Correct |
8 ms |
5468 KB |
Output is correct |
13 |
Correct |
10 ms |
5468 KB |
Output is correct |
14 |
Correct |
11 ms |
5468 KB |
Output is correct |
15 |
Correct |
100 ms |
9400 KB |
Output is correct |
16 |
Correct |
100 ms |
10068 KB |
Output is correct |
17 |
Correct |
93 ms |
9416 KB |
Output is correct |
18 |
Correct |
98 ms |
9392 KB |
Output is correct |
19 |
Correct |
257 ms |
16980 KB |
Output is correct |
20 |
Correct |
186 ms |
13660 KB |
Output is correct |
21 |
Correct |
279 ms |
17912 KB |
Output is correct |
22 |
Correct |
276 ms |
18008 KB |
Output is correct |