Submission #598966

# Submission time Handle Problem Language Result Execution time Memory
598966 2022-07-19T08:27:08 Z pakhomovee Wombats (IOI13_wombats) C++17
39 / 100
20000 ms 93220 KB
#include "wombats.h"
#include <algorithm>
#include <vector>
#include <queue>
#include <cassert>

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; 
    recalc();
}

int escape(int V1, int V2) {
    assert(V1 < m);
    assert(V2 < m);
    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 62 ms 4512 KB Output is correct
2 Correct 63 ms 4504 KB Output is correct
3 Correct 128 ms 7300 KB Output is correct
4 Correct 63 ms 4436 KB Output is correct
5 Correct 63 ms 4532 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 292 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 272 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 2 ms 340 KB Output is correct
8 Correct 2 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 82 ms 1316 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11918 ms 1352 KB Output is correct
2 Correct 17063 ms 1508 KB Output is correct
3 Correct 11527 ms 1460 KB Output is correct
4 Correct 11545 ms 1356 KB Output is correct
5 Correct 11451 ms 1332 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 340 KB Output is correct
9 Execution timed out 20009 ms 1420 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 367 ms 8732 KB Output is correct
2 Correct 851 ms 8788 KB Output is correct
3 Correct 344 ms 8792 KB Output is correct
4 Correct 400 ms 10156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11556 ms 1308 KB Output is correct
2 Correct 16988 ms 1464 KB Output is correct
3 Correct 11609 ms 1396 KB Output is correct
4 Correct 11595 ms 1480 KB Output is correct
5 Correct 11478 ms 1468 KB Output is correct
6 Correct 343 ms 8788 KB Output is correct
7 Correct 837 ms 8788 KB Output is correct
8 Correct 356 ms 8796 KB Output is correct
9 Correct 371 ms 10164 KB Output is correct
10 Correct 61 ms 4532 KB Output is correct
11 Correct 62 ms 4528 KB Output is correct
12 Correct 121 ms 7244 KB Output is correct
13 Correct 60 ms 4436 KB Output is correct
14 Correct 59 ms 4536 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 296 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 300 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 1 ms 296 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 1 ms 392 KB Output is correct
25 Correct 66 ms 2712 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Execution timed out 20027 ms 1356 KB Time limit exceeded
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13005 ms 1304 KB Output is correct
2 Correct 18616 ms 1468 KB Output is correct
3 Correct 12821 ms 1400 KB Output is correct
4 Correct 13634 ms 1352 KB Output is correct
5 Correct 11521 ms 1384 KB Output is correct
6 Correct 349 ms 8796 KB Output is correct
7 Correct 835 ms 8792 KB Output is correct
8 Correct 348 ms 8792 KB Output is correct
9 Correct 379 ms 10180 KB Output is correct
10 Correct 59 ms 4436 KB Output is correct
11 Correct 61 ms 4436 KB Output is correct
12 Correct 122 ms 7296 KB Output is correct
13 Correct 59 ms 4536 KB Output is correct
14 Correct 61 ms 4536 KB Output is correct
15 Execution timed out 20015 ms 93220 KB Time limit exceeded
16 Halted 0 ms 0 KB -