Submission #786565

# Submission time Handle Problem Language Result Execution time Memory
786565 2023-07-18T09:18:24 Z drdilyor Wombats (IOI13_wombats) C++17
0 / 100
120 ms 8676 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;

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];
        }
    }

    dist = vector(c, vector(c, 0ll));
    for (int v2 = 0; v2 < c; v2++) {
        vector<ll> dp(c, 0);
        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 changeH(int p, int q, int w) {
    level[p][q] = w;
}

void changeV(int p, int q, int w) {
    pass[p][q] = w;
}

int escape(int v1, int 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 3 ms 4564 KB Output is correct
2 Incorrect 3 ms 4564 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 1 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 119 ms 616 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 8676 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 120 ms 612 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 112 ms 616 KB Output isn't correct
2 Halted 0 ms 0 KB -