제출 #1000624

#제출 시각아이디문제언어결과실행 시간메모리
1000624nmts경주 (Race) (IOI11_race)C++17
컴파일 에러
0 ms0 KiB
#include <iostream>
#include <vector>
#include <algorithm>

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;
}


컴파일 시 표준 에러 (stderr) 메시지

race.cpp: In function 'int best_path(int, int, std::vector<std::vector<int> >&, std::vector<int>&)':
race.cpp:35:23: error: 'INT_MAX' was not declared in this scope
   35 |     int minHighways = INT_MAX;
      |                       ^~~~~~~
race.cpp:4:1: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
    3 | #include <algorithm>
  +++ |+#include <climits>
    4 |