Submission #1074518

# Submission time Handle Problem Language Result Execution time Memory
1074518 2024-08-25T10:54:32 Z deera Wombats (IOI13_wombats) C++14
39 / 100
20000 ms 17492 KB
#include <bits/stdc++.h>
using namespace std;
#include "wombats.h"
 
const int M = 5000;
const int N = 200;
 
int R, C;
int H[M][N], V[M][N];

int CACHE[N][N];
void solve(int a, int b) {
    int dp[1000];
    for (int &x : dp) x = 1e9;
    
    dp[a] = 0;
    for (int i = 0; i <= R - 1; i++) {
        for (int j = 0; i && j < C; j++)
            dp[j] += V[i - 1][j];
        for (int j = 0; j < C - 1; j++)
            dp[j + 1] = min(dp[j + 1], dp[j] + H[i][j]);
        for (int j = C - 2; j >= 0; j--)
            dp[j] = min(dp[j], dp[j + 1] + H[i][j]);
    }
    CACHE[a][b] = dp[b];
}
 
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 - 1; j++)
            H[i][j] = _H[i][j];
 
    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 < C; i++)
        for (int j = 0; j < C; j++)
            solve(i, j);
}
 
void changeH(int P, int Q, int W) {
    H[P][Q] = W;
    for (int i = 0; i < C; i++)
        for (int j = 0; j < C; j++)
            solve(i, j);
}
 
void changeV(int P, int Q, int W) {
    V[P][Q] = W;
    for (int i = 0; i < C; i++)
        for (int j = 0; j < C; j++)
            solve(i, j);
}
 
int escape(int a, int b) {
    return CACHE[a][b];
}

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;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 8 ms 8536 KB Output is correct
2 Correct 8 ms 8536 KB Output is correct
3 Correct 44 ms 11360 KB Output is correct
4 Correct 8 ms 8536 KB Output is correct
5 Correct 8 ms 8540 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2580 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 2504 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 2 ms 4440 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 51 ms 6936 KB Output is correct
12 Correct 2 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 20010 ms 4836 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 85 ms 15960 KB Output is correct
2 Correct 85 ms 16132 KB Output is correct
3 Correct 84 ms 15964 KB Output is correct
4 Correct 112 ms 17492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 20058 ms 4844 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 20047 ms 2652 KB Time limit exceeded
2 Halted 0 ms 0 KB -