답안 #598941

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
598941 2022-07-19T08:14:45 Z pakhomovee 웜뱃 (IOI13_wombats) C++17
12 / 100
12003 ms 8788 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) {
    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 * Q].back().second = W;
    g[P * 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;
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 4520 KB Output is correct
2 Incorrect 60 ms 4532 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 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 2 ms 296 KB Output is correct
11 Correct 68 ms 2728 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11834 ms 1392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 385 ms 8788 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12003 ms 1388 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11786 ms 1388 KB Output isn't correct
2 Halted 0 ms 0 KB -