Submission #598953

# Submission time Handle Problem Language Result Execution time Memory
598953 2022-07-19T08:20:57 Z pakhomovee Wombats (IOI13_wombats) C++17
12 / 100
12199 ms 8852 KB
#include "wombats.h"
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

int n, m;
vector<vector<pair<int, int>>> g;

int calc[200][200];
int dist[5000 * 200];
bool used[5000 * 200];
const int inf = 2e9;

void djkstra(int v, vector<vector<pair<int, int>>> &g, int* arr) {
    priority_queue<pair<int, int>> q;
    fill(dist, dist + n * m, inf);
    fill(used, used + n * m, false);
    dist[v] = 0;
    q.push({ -dist[v], v });
    while (!q.empty()) {
        int u = q.top().second;
        q.pop();
        if (used[u]) continue;
        used[u] = true;
        for (auto [c, w] : g[u]) {
            if (dist[c] > dist[u] + w) {
                dist[c] = dist[u] + w;
                q.push({ -dist[c], c });
            }
        }
    }
    for (int i = (n - 1) * m; i < n * m; ++i) {
        arr[i - (n - 1) * m] = dist[i];
    }
}

void recalc() {
    for (int i = 0; i < m; ++i) {
        djkstra(i, g, calc[i]);
    }
}

void init(int R, int C, int H[5000][200], int V[5000][200]) {
    n = R;
    m = C;
    g.resize(n * m);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j + 1 < m; ++j) {
            g[i * m + j].push_back({ i * m + j + 1, H[i][j] });
            g[i * m + j + 1].push_back({ i * m + j, H[i][j] });
        }
    }
    for (int i = 0; i + 1 < n; ++i) {
        for (int j = 0; j < m; ++j) {
            g[i * m + j].push_back({ i * m + j + m, V[i][j] });
        }
    }
    recalc();
}

void changeH(int P, int Q, int W) {
    if (Q == 0) {
        g[P * m + Q][0].second = W;
    } else {
        g[P * m + Q][1].second = W;
    }
    g[P * m + Q + 1][0].second = W;
    recalc();
}

void changeV(int P, int Q, int W) {
    g[P * m + Q].back().second = W;
    g[P * m + Q + m].back().second = W;
    recalc();
}

int escape(int V1, int V2) {
    return calc[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 61 ms 4496 KB Output is correct
2 Runtime error 60 ms 8852 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 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 2 ms 396 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 2 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 66 ms 1320 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 11890 ms 1308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 375 ms 8716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12199 ms 1304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12035 ms 1364 KB Output isn't correct
2 Halted 0 ms 0 KB -