Submission #786589

# Submission time Handle Problem Language Result Execution time Memory
786589 2023-07-18T09:37:48 Z drdilyor Wombats (IOI13_wombats) C++17
55 / 100
20000 ms 16652 KB
#include<bits/stdc++.h>
#include "wombats.h"
using namespace std;
const int inf = 1e9;
using ll = long long;
constexpr ll infl = 1e18;

int sum = 0;
int r, c;
vector<vector<int>> level;
vector<vector<int>> pass;
vector<vector<ll>> dist;

vector<int> dirty;

void update(int v2) {
    if (!dirty[v2]) return;
    dirty[v2] = 1;

    vector<ll> dp(c, infl);
    dp[v2] = 0;
    for (int i = r-1; i >= 0; i--) {
        vector<ll> ndp(c, infl);
        for (int j = 0; j < c; j++) {
            for (ll k = j - 1, sum = 0; k >= 0; k--) {
                sum += level[i][k];
                ndp[j] = min(ndp[j], dp[k] + sum);
            }
            for (ll k = j, sum = 0; k < c; k++) {
                ndp[j] = min(ndp[j], dp[k] + sum);
                if (k < c-1) sum += level[i][k];
            }
            if (i) ndp[j] += pass[i-1][j];
        }
        dp.swap(ndp);
    }
    for (int v1 = 0; v1 < c; v1++)
        dist[v1][v2] = dp[v1];
}

void init(int r, int c, int h[5000][200], int v[5000][200]) {
    // assert(c<= 2 || (r <= 100 && c <= 100));
    ::r = r;
    ::c = c;
    level.resize(r);
    for (int i = 0; i < r; i++) {
        level[i].resize(c-1);
        for (int j = 0; j < c-1; j++) {
            level[i][j] = h[i][j];
        }
    }

    pass.resize(r-1);
    for (int i = 0; i < r-1; i++) {
        pass[i].resize(c);
        for (int j = 0; j < c; j++) {
            pass[i][j] = v[i][j];
        }
    }
    dirty.assign(c, 1);
    dist = vector(c, vector(c, 0ll));
}

void changeH(int p, int q, int w) {
    level[p][q] = w;
    dirty.assign(c, 1);
}

void changeV(int p, int q, int w) {
    pass[p][q] = w;
    dirty.assign(c, 1);
}

int escape(int v1, int v2) {
    update(v2);
    return dist[v1][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;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 35 ms 4564 KB Output is correct
2 Correct 36 ms 4596 KB Output is correct
3 Correct 13331 ms 6120 KB Output is correct
4 Correct 35 ms 4564 KB Output is correct
5 Correct 39 ms 4612 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 4 ms 340 KB Output is correct
5 Correct 4 ms 340 KB Output is correct
6 Correct 5 ms 340 KB Output is correct
7 Correct 4 ms 304 KB Output is correct
8 Correct 3 ms 340 KB Output is correct
9 Correct 4 ms 340 KB Output is correct
10 Correct 3 ms 340 KB Output is correct
11 Correct 1832 ms 1312 KB Output is correct
12 Correct 4 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 120 ms 636 KB Output is correct
2 Correct 111 ms 620 KB Output is correct
3 Correct 115 ms 616 KB Output is correct
4 Correct 130 ms 616 KB Output is correct
5 Correct 119 ms 612 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 114 ms 596 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 106 ms 8660 KB Output is correct
2 Correct 97 ms 8660 KB Output is correct
3 Correct 97 ms 8660 KB Output is correct
4 Correct 9337 ms 9380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 132 ms 628 KB Output is correct
2 Correct 113 ms 596 KB Output is correct
3 Correct 115 ms 616 KB Output is correct
4 Correct 114 ms 616 KB Output is correct
5 Correct 118 ms 612 KB Output is correct
6 Correct 98 ms 8660 KB Output is correct
7 Correct 108 ms 8660 KB Output is correct
8 Correct 100 ms 8664 KB Output is correct
9 Correct 9700 ms 9432 KB Output is correct
10 Correct 35 ms 4564 KB Output is correct
11 Correct 37 ms 4592 KB Output is correct
12 Correct 13590 ms 6200 KB Output is correct
13 Correct 35 ms 4608 KB Output is correct
14 Correct 36 ms 4564 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 4 ms 340 KB Output is correct
19 Correct 5 ms 340 KB Output is correct
20 Correct 4 ms 340 KB Output is correct
21 Correct 4 ms 340 KB Output is correct
22 Correct 3 ms 340 KB Output is correct
23 Correct 4 ms 340 KB Output is correct
24 Correct 3 ms 340 KB Output is correct
25 Correct 1832 ms 1304 KB Output is correct
26 Correct 4 ms 340 KB Output is correct
27 Correct 114 ms 596 KB Output is correct
28 Execution timed out 20065 ms 12488 KB Time limit exceeded
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 113 ms 620 KB Output is correct
2 Correct 111 ms 636 KB Output is correct
3 Correct 114 ms 596 KB Output is correct
4 Correct 114 ms 616 KB Output is correct
5 Correct 112 ms 620 KB Output is correct
6 Correct 97 ms 8660 KB Output is correct
7 Correct 107 ms 8652 KB Output is correct
8 Correct 98 ms 8660 KB Output is correct
9 Correct 9759 ms 9432 KB Output is correct
10 Correct 35 ms 4564 KB Output is correct
11 Correct 36 ms 4564 KB Output is correct
12 Correct 13419 ms 6172 KB Output is correct
13 Correct 36 ms 4564 KB Output is correct
14 Correct 56 ms 4564 KB Output is correct
15 Correct 1486 ms 16652 KB Output is correct
16 Execution timed out 20099 ms 16648 KB Time limit exceeded
17 Halted 0 ms 0 KB -