#include <iostream>
#include <vector>
#include <set>
#include <cassert>
#include <queue>
#include <map>
#include <algorithm>
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(xs) xs.begin(), xs.end()
#define pb push_back
#define _1 first
#define _2 second
#define INF 1145141919
#define MOD 1000000000
using namespace std;
int DX[4] = {-1, 0, 1, 0};
int DY[4] = {0, -1, 0, 1};
typedef pair<int, int> P;
int mp[2010][2010];
int D[2000][2000];
int DistanceSum(int N, int *X, int *Y) {
if (N > 2000) abort();
int mx = *min_element(X, X+N), my = *min_element(Y, Y+N);
mx -= 5, my -= 5;
rep(i, N) X[i] -= mx, Y[i] -= my;
rep(i, 2010) rep(j, 2010) mp[i][j] = -1;
rep(i, N) mp[X[i]][Y[i]] = i;
rep(i, N) rep(j, N) D[i][j] = INF;
rep(s, N) {
queue<int> q;
q.push(s);
D[s][s] = 0;
while (!q.empty()) {
int x = q.front();
q.pop();
rep(k, 4) {
int t = mp[X[x]+DX[k]][Y[x]+DY[k]];
if (t != -1 && D[s][t] == INF) {
D[s][t] = D[s][x]+1;
q.push(t);
}
}
}
}
int s = 0;
rep(i, N) rep(j, i) s = (s + D[i][j]) % MOD;
return s;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
33560 KB |
Output is correct |
2 |
Correct |
0 ms |
33560 KB |
Output is correct |
3 |
Correct |
6 ms |
33560 KB |
Output is correct |
4 |
Correct |
3 ms |
33560 KB |
Output is correct |
5 |
Correct |
6 ms |
33560 KB |
Output is correct |
6 |
Correct |
3 ms |
33560 KB |
Output is correct |
7 |
Correct |
3 ms |
33560 KB |
Output is correct |
8 |
Correct |
9 ms |
33560 KB |
Output is correct |
9 |
Correct |
3 ms |
33560 KB |
Output is correct |
10 |
Correct |
6 ms |
33560 KB |
Output is correct |
11 |
Correct |
0 ms |
33560 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
53 ms |
33560 KB |
Output is correct |
2 |
Correct |
46 ms |
33560 KB |
Output is correct |
3 |
Correct |
129 ms |
33560 KB |
Output is correct |
4 |
Correct |
103 ms |
33560 KB |
Output is correct |
5 |
Correct |
233 ms |
33560 KB |
Output is correct |
6 |
Correct |
166 ms |
33560 KB |
Output is correct |
7 |
Correct |
239 ms |
33560 KB |
Output is correct |
8 |
Correct |
139 ms |
33560 KB |
Output is correct |
9 |
Correct |
149 ms |
33560 KB |
Output is correct |
10 |
Correct |
149 ms |
33560 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
33704 KB |
Execution killed because of forbidden syscall gettid (186) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
6 ms |
33704 KB |
Execution killed because of forbidden syscall gettid (186) |
2 |
Halted |
0 ms |
0 KB |
- |