Submission #990987

# Submission time Handle Problem Language Result Execution time Memory
990987 2024-06-01T03:19:15 Z vjudge1 Crocodile's Underground City (IOI11_crocodile) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
#define ALL(a) a.begin(), a.end()
using pii = pair<int, int>;
const int N = 1e3 + 5;

vector<pii> adj[N];
int cnt[N];

void connect(int u, int v, int w) {
    adj[u].emplace_back(v, w);
    adj[v].emplace_back(u, w);
}

int travel_plan(int n, const vector<int> &u, const vector<int> &v, const vector<int> &l, const vector<int> &a) {
    int nEdges = u.size();
    int nExits = a.size();
    priority_queue<pii, vector<pii>, greater<pii>> Q;

    for(int i = 0; i < nEdges; i++)
        connect(u[i], v[i], l[i]);

    for(int i = 0; i < nExits; i++) {
        cnt[a[i]]++;
        Q.emplace(0, a[i]);
    }

    for(int i = 0; i < n; i++)
        sort(ALL(adj[i]), [&](pii a, pii b) {
        return a.second < b.second;
    });

    int ans = -1;

    while(!Q.empty()) {
        auto [weight, u] = Q.top();
        Q.pop();
        cnt[u]++;

        if(cnt[u] == 2) {
            for(auto [v, w] : adj[u]) {
                if(v == 0) {
                    ans = weight + w;
                    break;
                }

                Q.emplace(weight + w, v);
            }
        }
    }

    return ans;
}

Compilation message

/usr/bin/ld: /tmp/ccd7SVaY.o: in function `main':
grader.cpp:(.text.startup+0x36): undefined reference to `travel_plan(int, int, int (*) [2], int*, int, int*)'
collect2: error: ld returned 1 exit status