/**
____ ____ ____ __________________ ____ ____ ____
||I || ||c || ||e || || || ||M || ||a || ||n ||
||__|| ||__|| ||__|| ||________________|| ||__|| ||__|| ||__||
|/__\| |/__\| |/__\| |/________________\| |/__\| |/__\| |/__\|
*/
#include "wombats.h"
#include <bits/stdc++.h>
#define maxn 5005
#define maxn2 205
using namespace std;
int c, r;
int h[maxn][maxn2];
int v[maxn][maxn2];
int dp[205][5005][205];
void calc_row(int i, int j)
{
for(int k = 1; k < c; k++)
dp[i][j][k] = min(dp[i][j][k], dp[i][j][k - 1] + h[j][k - 1]);
for(int k = c - 2; k > -1; k--)
dp[i][j][k] = min(dp[i][j][k], dp[i][j][k + 1] + h[i][k]);
}
void calc_dp(int i)
{
for(int j = 0; j < r; j++)
for(int k = 0; k < c; k++)
dp[i][j][k] = 1e9;
dp[i][0][i] = 0;
calc_row(i, 0);
for(int j = 1; j < r; j++)
{
for(int k = 0; k < c; k++)
dp[i][j][k] = dp[i][j - 1][k] + v[j - 1][k];
calc_row(i, j);
}
}
void init(int R, int C, int H[5000][200], int V[5000][200])
{
r = R;
c = C;
for(int i = 0; i < r; i++)
for(int j = 0; j < c; j++)
{
if(i + 1 < r)
v[i][j] = V[i][j];
if(j + 1 < c)
h[i][j] = H[i][j];
}
for(int i = 0; i < c; i++)
calc_dp(i);
}
void changeH(int P , int Q , int W)
{
h[P][Q] = W;
for(int i = 0; i < c; i++)
calc_dp(i);
}
void changeV(int P , int Q , int W)
{
v[P][Q] = W;
for(int i = 0; i < c; i++)
calc_dp(i);
}
int escape(int V1 , int V2)
{
return dp[V1][r - 1][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 |
13 ms |
16984 KB |
Output is correct |
2 |
Correct |
16 ms |
17072 KB |
Output is correct |
3 |
Correct |
68 ms |
19540 KB |
Output is correct |
4 |
Correct |
14 ms |
16988 KB |
Output is correct |
5 |
Correct |
17 ms |
16988 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4544 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Incorrect |
24 ms |
49900 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
872 ms |
220396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
74 ms |
26972 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
799 ms |
220144 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
809 ms |
220064 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |