#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pii;
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define eps (double)1e-9
#define PI 2*acos(0.0)
#define endl "\n"
#define sz(v) int((v).size())
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n;
ll x[100007], y[100007], ans, dist[2007][2007];
const ll mod = 1e9;
map <pii, int> id;
ll add(ll a, ll b){
a = ((a%mod)+mod)%mod;
b = ((b%mod)+mod)%mod;
return (a+b)%mod;
}
ll mult(ll a, ll b){
a = ((a%mod)+mod)%mod;
b = ((b%mod)+mod)%mod;
return (a*b)%mod;
}
ll calc(ll a){
return a*(a+1)/2;
}
int DistanceSum(int N, int *X, int *Y) {
int i, j;
n = N;
for(i = 0; i < n; i++){
x[i] = X[i];
y[i] = Y[i];
}
ll mx1 = 0, mn1 = 9e18, mx2 = 0, mn2 = 9e18;
for(i = 0; i < n; i++){
mx1 = max(mx1, x[i]);
mx2 = max(mx2, y[i]);
mn1 = min(mn1, x[i]);
mn2 = min(mn2, y[i]);
}
if((mx1-mn1+1)*(mx2-mn2+1) == n){
int nn = mx1-mn1+1, mm = mx2-mn2+1;
for(i = 1; i <= nn; i++){
for(j = 1; j <= mm; j++){
ans = add(ans, mult(mm, calc(nn-i)));
ans = add(ans, calc(mm-j));
ans = add(ans, mult(nn-i, add(calc(mm-j), calc(j-1))));
}
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
1024 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
1024 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |