Submission #1000625

#TimeUsernameProblemLanguageResultExecution timeMemory
1000625nmtsRace (IOI11_race)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
#include "race.h"
using namespace std;

struct Highway {
    int to;
    int length;
};

void dfs(int node, int parent, int K, int currentLength, int currentHighways, vector<vector<Highway>>& graph, int& minHighways) {
    if (currentLength > K) {
        return;
    }
    if (currentLength == K) {
        minHighways = min(minHighways, currentHighways);
        return;
    }

    for (const Highway& highway : graph[node]) {
        if (highway.to != parent) {
            dfs(highway.to, node, K, currentLength + highway.length, currentHighways + 1, graph, minHighways);
        }
    }
}

int best_path(int N, int K, vector<vector<int>>& H, vector<int>& L) {
    vector<vector<Highway>> graph(N);
    for (int i = 0; i < N - 1; ++i) {
        graph[H[i][0]].push_back({H[i][1], L[i]});
        graph[H[i][1]].push_back({H[i][0], L[i]});
    }

    int minHighways = INT_MAX;
    for (int i = 0; i < N; ++i) {
        dfs(i, -1, K, 0, 0, graph, minHighways);
    }

    return (minHighways == INT_MAX) ? -1 : minHighways;
}


Compilation message (stderr)

/usr/bin/ld: /tmp/ccSjR66t.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