This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define MOD 1000000000
#define INF 2147483646
#define min2(x,y) (x<y?x:y)
int n;
int cnt_X[100001], cnt_Y[100001];
int DistanceSum(int _n, int *X, int *Y) {
n = _n;
int x_min=INF, y_min=INF;
long long out = 0, t1, t2, t3;
for (int i = 0; i < n; i++) x_min = min2(x_min, X[i]), y_min = min2(y_min, Y[i]);
for (int i = 0; i < n; i++) cnt_X[X[i] - x_min]++, cnt_Y[Y[i] - y_min]++;
for (int i = 0; i<n; i++)
for (int j = i + 1; j < n; j++) {
t1 = cnt_X[i], t2 = cnt_X[j], t3 = j - i;
out += (t1*t2*t3) % MOD, out %= MOD;
}
for (int i = 0; i<n; i++)
for (int j = i + 1; j < n; j++) {
t1 = cnt_Y[i], t2 = cnt_Y[j], t3 = j - i;
out += (t1*t2*t3) % MOD, out %= MOD;
}
return (int)out;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |