답안 #786571

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
786571 2023-07-18T09:23:07 Z drdilyor 웜뱃 (IOI13_wombats) C++17
39 / 100
20000 ms 16268 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, 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 changeH(int p, int q, int w) {
    level[p][q] = w;

    for (int v2 = 0; v2 < c; v2++) {
        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 changeV(int p, int q, int w) {
    pass[p][q] = w;

    for (int v2 = 0; v2 < c; v2++) {
        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];
    }
}

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;
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 4596 KB Output is correct
2 Correct 43 ms 4588 KB Output is correct
3 Correct 89 ms 6144 KB Output is correct
4 Correct 49 ms 4596 KB Output is correct
5 Correct 36 ms 4564 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
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 69 ms 1248 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11280 ms 740 KB Output is correct
2 Correct 10849 ms 620 KB Output is correct
3 Correct 11357 ms 616 KB Output is correct
4 Correct 11217 ms 616 KB Output is correct
5 Correct 11083 ms 616 KB Output is correct
6 Correct 0 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 Execution timed out 20073 ms 616 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 101 ms 8660 KB Output is correct
2 Correct 108 ms 8672 KB Output is correct
3 Correct 100 ms 8660 KB Output is correct
4 Correct 127 ms 9336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11199 ms 620 KB Output is correct
2 Correct 10664 ms 612 KB Output is correct
3 Correct 11117 ms 620 KB Output is correct
4 Correct 11168 ms 620 KB Output is correct
5 Correct 10952 ms 596 KB Output is correct
6 Correct 100 ms 8636 KB Output is correct
7 Correct 100 ms 8660 KB Output is correct
8 Correct 101 ms 8660 KB Output is correct
9 Correct 129 ms 9436 KB Output is correct
10 Correct 38 ms 4564 KB Output is correct
11 Correct 36 ms 4592 KB Output is correct
12 Correct 96 ms 6144 KB Output is correct
13 Correct 37 ms 4564 KB Output is correct
14 Correct 39 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 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 60 ms 1284 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Execution timed out 20056 ms 616 KB Time limit exceeded
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11194 ms 612 KB Output is correct
2 Correct 10950 ms 620 KB Output is correct
3 Correct 11304 ms 616 KB Output is correct
4 Correct 11200 ms 624 KB Output is correct
5 Correct 10844 ms 620 KB Output is correct
6 Correct 100 ms 8660 KB Output is correct
7 Correct 100 ms 8660 KB Output is correct
8 Correct 101 ms 8660 KB Output is correct
9 Correct 130 ms 9384 KB Output is correct
10 Correct 36 ms 4564 KB Output is correct
11 Correct 37 ms 4564 KB Output is correct
12 Correct 95 ms 6096 KB Output is correct
13 Correct 37 ms 4564 KB Output is correct
14 Correct 40 ms 4608 KB Output is correct
15 Runtime error 140 ms 16268 KB Execution killed with signal 6
16 Halted 0 ms 0 KB -