Submission #763391

#TimeUsernameProblemLanguageResultExecution timeMemory
763391SanguineChameleonWombats (IOI13_wombats)C++17
0 / 100
24 ms34548 KiB
#include "wombats.h" #include <bits/stdc++.h> using namespace std; const int inf = 1e9 + 20; const int maxN = 5e3 + 20; const int maxM = 2e2 + 20; const int maxB = 1e3 + 20; int hor[maxN][maxM]; int ver[maxN][maxM]; int tmp[maxM][maxM]; int dp[maxM][maxM]; int tree[maxB][maxM][maxM]; int N, M; void calc(int id, int lt, int rt) { for (int X = 0; X < M; X++) { dp[lt][X] = 0; for (int i = X - 1; i >= 0; i--) { dp[lt][i] = dp[lt][i + 1] + hor[lt][i]; } for (int i = X + 1; i < M; i++) { dp[lt][i] = dp[lt][i - 1] + hor[lt][i - 1]; } for (int i = lt + 1; i <= rt; i++) { for (int j = 0; j < M; j++) { tmp[i][j] = dp[i - 1][j] + ver[i - 1][j]; dp[i][j] = tmp[i][j]; } int best = tmp[i][0]; for (int j = 1; j < M; j++) { best = min(best + hor[i][j - 1], tmp[i][j]); dp[i][j] = min(dp[i][j], best); } best = tmp[i][M - 1]; for (int j = M - 2; j >= 0; j--) { best = min(best + hor[i][j], tmp[i][j]); dp[i][j] = min(dp[i][j], best); } } for (int Y = 0; Y < M; Y++) { assert(X == 0 && Y == 0); tree[id][X][Y] = dp[rt][Y]; } } } void init(int R, int C, int H[5000][200], int V[5000][200]) { N = R; M = C; for (int i = 0; i < N; i++) { for (int j = 0; j < M - 1; j++) { hor[i][j] = H[i][j]; } } for (int i = 0; i < N - 1; i++) { for (int j = 0; j < M; j++) { ver[i][j] = V[i][j]; } } calc(1, 0, N - 1); } void changeH(int P, int Q, int W) { hor[P][Q] = W; calc(1, 0, N - 1); } void changeV(int P, int Q, int W) { ver[P][Q] = W; calc(1, 0, N - 1); } int escape(int X, int Y) { return tree[1][X][Y]; }

Compilation message (stderr)

grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
   15 |  int res;
      |      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...