#include <bits/stdc++.h>
#include "wombats.h"
using namespace std;
using ll = long long;
constexpr ll INF = 1000000000000000000LL;
ll n, m, q, k, x, y, a, b, c, l;
vector< vector<ll> > dp[100];
vector< vector<ll> > h;
vector< vector<ll> > v;
void make_dp(ll c) {
dp[c].assign(n, vector<ll> (m, INF));
dp[c][n - 1][c] = 0;
for (int i = n - 1; i >= 0; i--) {
if (i != n - 1) {
for (int j = 0; j < m; j++) {
dp[c][i][j] = min(dp[c][i][j], dp[c][i + 1][j] + v[i][j]);
}
}
for (int j = 1; j < m; j++) {
dp[c][i][j] = min(dp[c][i][j], dp[c][i][j - 1] + h[i][j - 1]);
}
for (int j = m - 2; j >= 0; j--) {
dp[c][i][j] = min(dp[c][i][j], dp[c][i][j + 1] + h[i][j]);
}
}
}
void init(int R, int C, int H[5000][200], int V[5000][200]) {
n = R;
m = C;
h.assign(n, vector<ll> (m - 1));
for (int i = 0; i < n; i++) {
for (int j = 0; j < m - 1; j++) {
h[i][j] = H[i][j];
}
}
v.assign(n - 1, vector<ll> (m));
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < m; j++) {
v[i][j] = V[i][j];
}
}
for (int i = 0; i < C; i++) {
make_dp(i);
}
}
void changeH(int P, int Q, int W) {
h[P][Q] = W;
for (int i = 0; i < m; i++) {
make_dp(i);
}
}
void changeV(int P, int Q, int W) {
v[P][Q] = W;
for (int i = 0; i < m; i++) {
make_dp(i);
}
}
int escape(int V1, int V2) {
return dp[V2][0][V1];
}
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 |
19 ms |
5208 KB |
Output is correct |
2 |
Correct |
19 ms |
5212 KB |
Output is correct |
3 |
Correct |
57 ms |
7928 KB |
Output is correct |
4 |
Correct |
18 ms |
5212 KB |
Output is correct |
5 |
Correct |
21 ms |
5420 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 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 |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
43 ms |
3424 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
308 ms |
10844 KB |
Output is correct |
2 |
Correct |
306 ms |
10676 KB |
Output is correct |
3 |
Correct |
308 ms |
10840 KB |
Output is correct |
4 |
Correct |
306 ms |
11016 KB |
Output is correct |
5 |
Correct |
297 ms |
10796 KB |
Output is correct |
6 |
Correct |
0 ms |
600 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1500 ms |
10820 KB |
Output is correct |
10 |
Correct |
1 ms |
2652 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
64 ms |
9364 KB |
Output is correct |
2 |
Correct |
65 ms |
9396 KB |
Output is correct |
3 |
Correct |
64 ms |
9304 KB |
Output is correct |
4 |
Correct |
90 ms |
10656 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
310 ms |
10840 KB |
Output is correct |
2 |
Correct |
300 ms |
10832 KB |
Output is correct |
3 |
Correct |
309 ms |
10840 KB |
Output is correct |
4 |
Correct |
308 ms |
10840 KB |
Output is correct |
5 |
Correct |
296 ms |
10836 KB |
Output is correct |
6 |
Correct |
65 ms |
9304 KB |
Output is correct |
7 |
Correct |
65 ms |
9304 KB |
Output is correct |
8 |
Correct |
65 ms |
9416 KB |
Output is correct |
9 |
Correct |
92 ms |
10576 KB |
Output is correct |
10 |
Correct |
29 ms |
5208 KB |
Output is correct |
11 |
Correct |
35 ms |
5212 KB |
Output is correct |
12 |
Correct |
59 ms |
8016 KB |
Output is correct |
13 |
Correct |
18 ms |
5208 KB |
Output is correct |
14 |
Correct |
36 ms |
5208 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
2476 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2396 KB |
Output is correct |
23 |
Correct |
1 ms |
2396 KB |
Output is correct |
24 |
Correct |
1 ms |
2396 KB |
Output is correct |
25 |
Correct |
45 ms |
4800 KB |
Output is correct |
26 |
Correct |
1 ms |
2392 KB |
Output is correct |
27 |
Correct |
1666 ms |
11028 KB |
Output is correct |
28 |
Runtime error |
279 ms |
262144 KB |
Execution killed with signal 9 |
29 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
349 ms |
10844 KB |
Output is correct |
2 |
Correct |
316 ms |
10700 KB |
Output is correct |
3 |
Correct |
339 ms |
10844 KB |
Output is correct |
4 |
Correct |
339 ms |
11024 KB |
Output is correct |
5 |
Correct |
322 ms |
10780 KB |
Output is correct |
6 |
Correct |
66 ms |
9308 KB |
Output is correct |
7 |
Correct |
67 ms |
9308 KB |
Output is correct |
8 |
Correct |
69 ms |
9308 KB |
Output is correct |
9 |
Correct |
90 ms |
10576 KB |
Output is correct |
10 |
Correct |
23 ms |
5384 KB |
Output is correct |
11 |
Correct |
22 ms |
5212 KB |
Output is correct |
12 |
Correct |
94 ms |
8020 KB |
Output is correct |
13 |
Correct |
33 ms |
5412 KB |
Output is correct |
14 |
Correct |
21 ms |
5212 KB |
Output is correct |
15 |
Runtime error |
400 ms |
262144 KB |
Execution killed with signal 9 |
16 |
Halted |
0 ms |
0 KB |
- |