답안 #1074165

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1074165 2024-08-25T08:32:00 Z deera 웜뱃 (IOI13_wombats) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
// #include "wombats.h"

const int M = 5000;
const int N = 200;

int R, C;
// tuple<from, to, weight>
vector<tuple<int, int, int>> edges;
const int MAX = 1000'000;
vector<vector<pair<int, int>>> adj(MAX, vector<pair<int, int>>());

void init(int _R, int _C, int H[5000][200], int V[5000][200]) {
    R = _R;
    C = _C;

    // for (int i = 0; i < R; i++)
    //     for (int j = 0; j < C - 1; j++)
    //         H[i][j] = _H[i][j], sum += H[i][j];

    // for (int i = 0; i < R - 1; i++)
    //     for (int j = 0; j < C; j++)
    //         V[i][j] = _V[i][j], sum += V[i][j];

    for (int i = 0; i < R; i++)
        for (int j = 0; j < C - 1; j++)
            // edges.push_back({i * 5000 + j, i * 5000 + (j + 1), H[i][j]}),
            {
                int a = i * 5000 + j;
                int b = i * 5000 + (j + 1);

                adj[a].push_back({b, H[i][j]});
                adj[b].push_back({a, H[i][j]});
            }

    for (int i = 0; i < R - 1; i++)
        for (int j = 0; j < C; j++)
            // edges.push_back({i * 5000 + j, (i + 1) * 5000 + j, V[i][j]});
            {
                int a = i * 5000 + j;
                int b = (i + 1) * 5000 + j;

                adj[a].push_back({b, V[i][j]});
                adj[b].push_back({a, V[i][j]});
            }
}

void changeH(int P, int Q, int W) {
}

void changeV(int P, int Q, int W) {
}

int escape(int V1, int V2) {
    int a = 0 * 5000 + V1;
    int b = (R - 1) * 5000 + V2;

    vector<int> dist(MAX, INT_MAX);
    dist[a] = 0;
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
    pq.push({0, a});

    while (!pq.empty()) {
        auto [d, u] = pq.top();
        pq.pop();

        if (d > dist[u])
            continue;

        for (auto [v, w] : adj[u]) {
            if (dist[u] + w < dist[v]) {
                dist[v] = dist[u] + w;
                pq.push({dist[v], v});
            }
        }
    }

    return dist[b];
}

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;
      |      ^~~
wombats.cpp: In function 'int escape(int, int)':
wombats.cpp:65:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   65 |         auto [d, u] = pq.top();
      |              ^
wombats.cpp:71:19: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   71 |         for (auto [v, w] : adj[u]) {
      |                   ^
/usr/bin/ld: /tmp/ccS3d815.o: in function `main':
grader.c:(.text.startup+0x129): undefined reference to `init'
/usr/bin/ld: grader.c:(.text.startup+0x194): undefined reference to `escape'
/usr/bin/ld: grader.c:(.text.startup+0x203): undefined reference to `changeH'
/usr/bin/ld: grader.c:(.text.startup+0x26d): undefined reference to `changeV'
collect2: error: ld returned 1 exit status