// Ignut
#include <bits/stdc++.h>
#include "wombats.h"
using namespace std;
using ll = long long;
// const int H = 5555, W = 222;
int h, w;
vector<vector<int>> dwn, rht;
vector<vector<int>> pref;
void init(int R, int C, int H[5000][200], int V[5000][200]) {
h = R, w = C;
dwn.assign(h, {});
rht.assign(h, {});
pref.assign(h, {});
for (int i = 0; i < h - 1; i ++)
for (int j = 0; j < w; j ++)
dwn[i].push_back(V[i][j]);
for (int i = 0; i < h; i ++) {
pref[i].push_back(0);
for (int j = 0; j < w - 1; j ++) {
rht[i].push_back(H[i][j]);
pref[i].push_back(pref[i].back() + H[i][j]);
}
}
}
void changeH(int P, int Q, int W) {
rht[P][Q] = w;
pref[P] = {0};
for (int j = 0; j < w - 1; j ++)
pref[P].push_back(pref[P].back() + rht[P][j]);
}
void changeV(int P, int Q, int W) {
dwn[P][Q] = W;
}
const int INF = 1e9 + 123;
int escape(int V1, int V2) {
vector<int> dist(w, INF);
dist[V1] = 0;
for (int i = 0; i < h; i ++) {
for (int j1 = 0; j1 < w; j1 ++) {
for (int j2 = 0; j2 < w; j2 ++) {
dist[j1] = min(dist[j1], dist[j2] + abs(pref[i][j1] - pref[i][j2]));
}
}
if (i + 1 < h)
for (int j = 0; j < w; j ++)
dist[j] += dwn[i][j];
}
return dist[V2];
}
Compilation message
grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
15 | int res;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
4956 KB |
Output is correct |
2 |
Correct |
8 ms |
4864 KB |
Output is correct |
3 |
Correct |
2441 ms |
7568 KB |
Output is correct |
4 |
Correct |
8 ms |
4956 KB |
Output is correct |
5 |
Correct |
9 ms |
4812 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
4 ms |
2528 KB |
Output is correct |
5 |
Correct |
4 ms |
2396 KB |
Output is correct |
6 |
Correct |
4 ms |
2396 KB |
Output is correct |
7 |
Correct |
4 ms |
2396 KB |
Output is correct |
8 |
Correct |
3 ms |
2396 KB |
Output is correct |
9 |
Correct |
4 ms |
2396 KB |
Output is correct |
10 |
Correct |
4 ms |
2648 KB |
Output is correct |
11 |
Correct |
1773 ms |
4676 KB |
Output is correct |
12 |
Correct |
4 ms |
2392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
106 ms |
2788 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
63 ms |
9052 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
105 ms |
2648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
106 ms |
2648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |