Submission #1068078

# Submission time Handle Problem Language Result Execution time Memory
1068078 2024-08-21T07:11:26 Z thinknoexit Wombats (IOI13_wombats) C++17
0 / 100
16 ms 24152 KB
#include "wombats.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 5000;
const int M = 100;
int rc[N][M]; // cost from (i, j) -> (i+1, j)
int cc[N][M]; // cost from (i, j) -> (i, j+1)
int n, m;
struct A {
    vector<vector<int>> dis;
    int r;
    void init() {
        dis.assign(m, vector<int>(m, 1e9));
    }
    A operator + (const A& o) const {
        A res;
        res.init();
        for (int i = 0;i < m;i++) {
            for (int j = 0;j < m;j++) {
                for (int k = 0;k < m;k++) {
                    res.dis[i][j] = min(res.dis[i][j],
                        dis[i][k] + rc[r][k] + o.dis[k][j]);
                }
            }
        }
        res.r = o.r;
        return res;
    }
} now;
A cal(int r) {
    A now;
    vector<int> sum(m);
    sum[0] = 0;
    for (int i = 1;i < m;i++) {
        sum[i] = sum[i - 1] + cc[r][i - 1];
    }
    for (int i = 0;i < m;i++) {
        for (int j = i;j < m;j++) {
            now.dis[i][j] = now.dis[j][i] = sum[j] - sum[i];
        }
    }
    now.r = r;
    return now;
}
void init(int R, int C, int H[5000][200], int V[5000][200]) {
    n = R, m = C;
    for (int i = 0;i < n - 1;i++) {
        for (int j = 0;j < m;j++) {
            rc[i][j] = V[i][j];
        }
    }
    for (int i = 0;i < n;i++) {
        for (int j = 0;j < m - 1;j++) {
            cc[i][j] = H[i][j];
        }
    }
    now = cal(0);
    for (int i = 1;i < n;i++) now = now + cal(i);
}

void changeH(int P, int Q, int W) {
    cc[P][Q] = W;
    now = cal(0);
    for (int i = 1;i < n;i++) {
        now = now + cal(i);
    }
}

void changeV(int P, int Q, int W) {
    rc[P][Q] = W;
    now = cal(0);
    for (int i = 1;i < n;i++) {
        now = now + cal(i);
    }
}

int escape(int V1, int V2) {
    return now.dis[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 Runtime error 7 ms 12380 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 16 ms 24152 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -