#include "wombats.h"
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
template <typename T>
using ve = vector<T>;
int r, c, at[9999], h[5000][200], v[5000][200];
int sum = 0;
int c_is_2_dp() {
static int dp[5001][2];
dp[0][0] = dp[0][1] = 0;
for (int i = 1; i <= r; ++i) {
dp[i][0] = dp[i - 1][0] + h[i - 1][0];
dp[i][1] = dp[i - 1][1] + h[i - 1][1];
dp[i][0] = min(dp[i][0], dp[i][1] + v[i][0]);
dp[i][1] = min(dp[i][1], dp[i][0] + v[i][0]);
}
return min(dp[r][0], dp[r][1]);
}
void changeH(int P, int Q, int W) {
if (c == 2) {
h[P][Q] = W;
}
/* ... */
}
void changeV(int P, int Q, int W) {
if (c == 1) {
sum += W - at[P];
at[P] = W;
} else if (c == 2) {
v[P][Q] = W;
}
/* ... */
}
void init(int R, int C, int H[5000][200], int V[5000][200]) {
r = R, c = C;
if (c == 1)
for (int i = 0; i < r; ++i) changeV(i, 0, V[i][0]);
else if (c == 2) {
for (int i = 0; i < r; ++i) changeV(i, 0, V[i][0]), changeV(i, 1, V[i][1]), changeH(i, 0, H[i][0]);
}
}
int escape(int V1, int V2) {
if (c == 1)
return sum;
else if (c == 2)
return c_is_2_dp();
}
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;
| ^~~
wombats.cpp: In function 'int escape(int, int)':
wombats.cpp:60:1: warning: control reaches end of non-void function [-Wreturn-type]
60 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4184 KB |
Output is correct |
2 |
Correct |
3 ms |
4184 KB |
Output is correct |
3 |
Correct |
38 ms |
5772 KB |
Output is correct |
4 |
Correct |
2 ms |
4188 KB |
Output is correct |
5 |
Correct |
2 ms |
4184 KB |
Output is correct |
6 |
Correct |
0 ms |
344 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 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
30 ms |
15960 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |