#include"bits/stdc++.h"
#define overload(a,b,c,d,...) d
#define rep1(a) for(ll _=0;_<(ll)a;++_)
#define rep2(i,n) for(ll i=0;i<(ll)n;++i)
#define rep3(i,l,r) for(ll i=(ll)l;i<(ll)r;++i)
#define rep(...) overload(__VA_ARGS__,rep3,rep2,rep1)(__VA_ARGS__)
#define rrep1(i,a) for(ll i=(ll)a-1;i>=0;--i)
#define rrep2(i,a,b) for(ll i=(ll)b-1;i>=(ll)a;--i)
#define rrep(...) overload(__VA_ARGS__,rrep2,rrep1)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
using namespace std;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
template<typename T,typename U>inline bool chmin(T&a,const U&b){return (a>b?a=b,true:false);}
template<typename T,typename U>inline bool chmax(T&a,const U&b){return (a<b?a=b,true:false);}
static constexpr ll mod1=998244353;
static constexpr ll mod=1000000007;
static constexpr ll inf=numeric_limits<ll>::max()/2;
int main(){
ll n;cin>>n;
map<ll,ll>cntx;
map<ll,vector<ll>>ys;
rep(i,n){
ll a,b;cin>>a>>b;
cntx[a]++;
ys[b].eb(a);
}
ll ans=0;
for(auto [y,v]:ys){
ll tmp=v.size()-1;
for(auto x:v)ans+=tmp*(cntx[x]-1);
}
cout<<ans<<endl;
}
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 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 |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
8 ms |
1628 KB |
Output is correct |
13 |
Correct |
9 ms |
1372 KB |
Output is correct |
14 |
Correct |
16 ms |
1884 KB |
Output is correct |
15 |
Correct |
135 ms |
8532 KB |
Output is correct |
16 |
Correct |
135 ms |
9056 KB |
Output is correct |
17 |
Correct |
134 ms |
8528 KB |
Output is correct |
18 |
Correct |
126 ms |
8528 KB |
Output is correct |
19 |
Correct |
342 ms |
15632 KB |
Output is correct |
20 |
Correct |
268 ms |
12624 KB |
Output is correct |
21 |
Correct |
372 ms |
16464 KB |
Output is correct |
22 |
Correct |
375 ms |
16244 KB |
Output is correct |