Submission #962138

# Submission time Handle Problem Language Result Execution time Memory
962138 2024-04-13T07:35:06 Z danikoynov Wombats (IOI13_wombats) C++14
28 / 100
3934 ms 169028 KB
#include "wombats.h"
#include<bits/stdc++.h>

using namespace std;

const int maxr = 2010, maxc = 210;

void precalculate();
int h[maxr][maxc], v[maxr][maxc], dp[maxc][maxr][maxc];
int r, c;
void init(int R, int C, int H[5000][200], int V[5000][200]) {
    /* ... */
    r = R;
    c = C;
    for (int i = 0; i < R - 1; i ++)
     for (int j = 0; j < C; j ++)
     v[i][j] = V[i][j];

    for (int i = 0; i < R; i ++)
     for (int j = 0; j < C - 1; j ++)
     h[i][j] = H[i][j];

     precalculate();
}

const int inf = 2e9 + 10;

void fix_row(int d, int i)
{
     for (int j = 1; j < c; j ++)
     {
          dp[d][i][j] = min(dp[d][i][j], dp[d][i][j - 1] + h[i][j - 1]);
     }
     for (int j = c - 2; j >= 0; j --)
     {
          dp[d][i][j] = min(dp[d][i][j], dp[d][i][j + 1] + h[i][j]);
     }
}

void calc_dp(int d)
{
     for (int i = 0; i < r;i  ++)
          for (int j = 0; j < c; j ++)
          dp[d][i][j] = inf;

     dp[d][0][d] = 0;
     fix_row(d, 0);

     for (int i = 1; i < r; i ++)
     {
          for (int j = 0; j < c; j ++)
          {
               dp[d][i][j] = dp[d][i - 1][j] + v[i - 1][j];
          }
          fix_row(d, i);
     }
}

void precalculate()
{
     for (int d = 0; d < c; d ++)
          calc_dp(d);
}
void changeH(int P, int Q, int W) {
    /* ... */
    h[P][Q] = W;
    precalculate();
}

void changeV(int P, int Q, int W) {
    /* ... */
    v[P][Q] = W;
    precalculate();
}

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;
      |      ^~~
wombats.cpp: In function 'void init(int, int, int (*)[200], int (*)[200])':
wombats.cpp:19:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   19 |     for (int i = 0; i < R; i ++)
      |     ^~~
wombats.cpp:23:6: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   23 |      precalculate();
      |      ^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 18 ms 23388 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4448 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 15 ms 41428 KB Output is correct
5 Correct 8 ms 41564 KB Output is correct
6 Correct 5 ms 41308 KB Output is correct
7 Correct 5 ms 41304 KB Output is correct
8 Correct 5 ms 39268 KB Output is correct
9 Correct 5 ms 41504 KB Output is correct
10 Correct 5 ms 39360 KB Output is correct
11 Correct 65 ms 43696 KB Output is correct
12 Correct 6 ms 41496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 870 ms 165176 KB Output is correct
2 Correct 774 ms 163112 KB Output is correct
3 Correct 795 ms 163220 KB Output is correct
4 Correct 818 ms 165184 KB Output is correct
5 Correct 803 ms 163128 KB Output is correct
6 Correct 1 ms 4696 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 3934 ms 163216 KB Output is correct
10 Correct 2 ms 14684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 20 ms 27576 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 796 ms 165176 KB Output is correct
2 Correct 783 ms 162900 KB Output is correct
3 Correct 814 ms 165180 KB Output is correct
4 Correct 801 ms 167144 KB Output is correct
5 Correct 778 ms 166996 KB Output is correct
6 Runtime error 20 ms 27408 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 803 ms 167136 KB Output is correct
2 Correct 791 ms 167036 KB Output is correct
3 Correct 818 ms 169028 KB Output is correct
4 Correct 801 ms 167144 KB Output is correct
5 Correct 794 ms 166996 KB Output is correct
6 Runtime error 21 ms 27484 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -