Submission #1361642

#TimeUsernameProblemLanguageResultExecution timeMemory
1361642midariRace (IOI11_race)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long

ll best_path(ll n, ll k, ll H[][2], ll L[]){
    vector<ll>adj[200100];
    ll dist[1005][1005];
    for (ll i=1; i<n; i++){
        ll u=H[i][0];
        ll v=H[i][1];
        ll l=L[i];
        adj[u].push_back(v);
        adj[v].push_back(u);
        dist[u][v]=l;
        dist[v][u]=l;
    }
    ll e=LLONG_MAX;
    ll dfh1[200100],dfh2[200100];
    for (ll i=1; i<=n; i++){
        queue<ll>q;
        q.push(i);
        ll vis[n+5]={0};
        dfh1[i]=0;
        dfh2[i]=0;
        while (!q.empty()){
            ll a=q.front();
            q.pop();
            vis[a]=1;
            for (auto u : adj[a]){
                if (vis[u]!=1){
                    vis[u]=1;
                    q.push(u);
                    dfh1[u]=dfh1[a]+dist[a][u];
                    dfh2[u]=dfh2[a]+1;
                    if (dfh1[u]==k){
                        e=min(e,dfh2[u]);
                    }
                }
            }
        }
    }
    if (e==LLONG_MAX){
        return -1;
    }
    else {
        return e;
    }
}

Compilation message (stderr)

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