#include <bits/stdc++.h>
using namespace std;
#define erorp(x) cout<<#x<<"={"<<(x.F)<<" , "<<x.S<<"}"<<endl
#define print(v,r) f(i,0,r) cout<<v[i]<<" "; cout<<endl
#define eror(x) cout<<#x<<'='<<(x)<<endl
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define nb(x) __builtin_popcount(x)
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define Add(x,y) x=(x+y)%mod
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first
const int N=1e6+99;
ll n,b[N],w[N];
pair<ll,ll> a[N];
vector<ll> g[N];
map<pair<ll,ll>,ll> edge,mark;
ll ans;
int s[N],t[N];
void solve(){
f(i,0,n) b[i]=a[i].F;
sort(b,b+n);
f(i,1,n){
if(b[i-1]!=b[i]){
ans+=1ll*i*(n-i);
}
}
}
ll DistanceSum(int N,int *X,int *Y){
n=N;
f(i,0,n) a[i].F=X[i],a[i].S=Y[i];
solve();
f(i,0,n) a[i].F=Y[i],a[i].S=X[i];
solve();
return ans;
}
/*
int main(){
int n;
cin>>n;
f(i,0,n) cin>>s[i]>>t[i];
cout<<DistanceSum(n,s,t);
}*/
/*
11
2 5
2 6
3 3
3 6
4 3
4 4
4 5
4 6
5 3
5 4
5 6
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
12 ms |
23756 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
12 ms |
23784 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
17 ms |
24396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
17 ms |
24480 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |