Submission #598999

# Submission time Handle Problem Language Result Execution time Memory
598999 2022-07-19T08:49:42 Z pakhomovee Wombats (IOI13_wombats) C++17
39 / 100
20000 ms 16792 KB
#include "wombats.h"
#include <algorithm>
#include <vector>
#include <set>
#include <cassert>
#include <cstring>

using namespace std;

int n, m;
int h[5000][200];
int v[5000][200];

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

void djkstra(int s, int* arr) {
    set<pair<int, int>> q;
    fill(dist, dist + n * m, inf);
    fill(used, used + n * m, false);
    dist[s] = 0;
    q.insert({ dist[s], s });
    while (!q.empty()) {
        int u = q.begin()->second;
        q.erase(q.begin());
        if (used[u]) continue;
        used[u] = true;
        int r = u / m;
        int c = u % m;
        if (r + 1 < n && dist[u + m] > dist[u] + v[r][c]) {
            q.erase({ dist[u + m], u + m });
            dist[u + m] = dist[u] + v[r][c];
            q.insert({ dist[u + m], u + m });
        }
        if (c > 0 && dist[u - 1] > dist[u] + h[r][c - 1]) {
            q.erase({ dist[u - 1], u - 1 });
            dist[u - 1] = dist[u] + h[r][c - 1];
            q.insert({ dist[u - 1], u - 1 });
        }
        if (c + 1 < m && dist[u + 1] > dist[u] + h[r][c]) {
            q.erase({ dist[u + 1], u + 1 });
            dist[u + 1] = dist[u] + h[r][c];
            q.insert({ dist[u + 1], u + 1 });
        }
    }
    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, calc[i]);
    }
}

void init(int R, int C, int H[5000][200], int V[5000][200]) {
    n = R;
    m = C;
    for (int i = 0; i < 5000; ++i) {
        memcpy(h[i], H[i], 200 * sizeof(int));
    }
    for (int i = 0; i < 5000; ++i) {
        memcpy(v[i], V[i], 200 * sizeof(int));
    }
    recalc();
}

void changeH(int P, int Q, int W) {
    h[P][Q] = W;
    recalc();
}

void changeV(int P, int Q, int W) {
    v[P][Q] = 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 134 ms 12060 KB Output is correct
2 Correct 139 ms 12064 KB Output is correct
3 Correct 216 ms 13620 KB Output is correct
4 Correct 121 ms 12060 KB Output is correct
5 Correct 135 ms 11988 KB Output is correct
6 Correct 7 ms 8020 KB Output is correct
7 Correct 5 ms 8148 KB Output is correct
8 Correct 5 ms 8148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 8148 KB Output is correct
2 Correct 6 ms 8148 KB Output is correct
3 Correct 6 ms 8148 KB Output is correct
4 Correct 9 ms 8192 KB Output is correct
5 Correct 7 ms 8148 KB Output is correct
6 Correct 7 ms 8148 KB Output is correct
7 Correct 7 ms 8184 KB Output is correct
8 Correct 7 ms 8080 KB Output is correct
9 Correct 7 ms 8148 KB Output is correct
10 Correct 10 ms 8116 KB Output is correct
11 Correct 81 ms 9180 KB Output is correct
12 Correct 9 ms 8148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 20098 ms 8420 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 912 ms 15992 KB Output is correct
2 Correct 1024 ms 15988 KB Output is correct
3 Correct 1034 ms 15992 KB Output is correct
4 Correct 1055 ms 16792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 20015 ms 8424 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 20095 ms 8428 KB Time limit exceeded
2 Halted 0 ms 0 KB -