#include <bits/stdc++.h>
using namespace std;
vector<int> G[2009]; int dist[2009], mod = 1000000000;
long long cx[200009], cy[200009];
int DistanceSum(int N, int *X, int *Y) {
if (N > 2) {
int minx = 2147483647, miny = 2147483647;
for (int i = 0; i < N; i++) { minx = min(minx, X[i]); miny = min(miny, Y[i]); }
for (int i = 0; i < N; i++) { cx[X[i] - minx]++; cy[Y[i] - miny]++; }
long long sum = 0;
for (int i = 0; i <= N; i++) sum += 1LL * cx[i] * (1LL * N - cx[i]);
for (int i = 0; i <= N; i++) sum += 1LL * cy[i] * (1LL * N - cy[i]);
return sum % mod;
}
else {
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
int V = abs(X[i] - X[j]) + abs(Y[i] - Y[j]);
if (V == 1) G[i].push_back(j);
}
}
int sum = 0;
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) dist[j] = 10000;
queue<int> que; que.push(i); dist[i] = 0;
while (!que.empty()) {
int pos = que.front(); que.pop();
for (int j = 0; j < (int)G[pos].size(); j++) {
if (dist[G[pos][j]] > dist[pos] + 1) {
dist[G[pos][j]] = dist[pos] + 1;
que.push(G[pos][j]);
}
}
}
for (int j = i + 1; j < N; j++) { sum += dist[j]; sum %= mod; }
}
return sum;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
512 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
644 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |