제출 #659855

#제출 시각아이디문제언어결과실행 시간메모리
659855Trisanu_Das경주 (Race) (IOI11_race)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std; 
int K, ans = INT_MAX; vector<pair<int, int>> adj[200005]; set<pair<int, int>> S[200005];
 
void dfs(int u, int p, int dis, int dep){
    S[u].insert({dis, dep});
    for (auto v : adj[u]) if (v.first != p){
        dfs(v.first, i, dis + v.second, dep + 1);
        if (S[i].size() < S[v.first].size()) swap(S[i], S[v.first]);
        for (auto d : S[v.first]){
            int other = K + 2 * dis - d.first; auto x = S[i].lower_bound({other, -1});
            if (x != S[i].end() and (*x).first == other) ans = min(ans, d.second + (*x).second - 2 * dep);
        }for (auto d : S[v.first]) S[i].insert(d);
    }
}
int best_path(int n, int k, int h[][2], int l[]){
    for (int i = 0; i < n - 1; i++){
        adj[h[i][0]].push_back({h[i][1], l[i]});
        adj[h[i][1]].push_back({h[i][0], l[i]});
    }K = k; dfs(0, 0, 0, 0); return (ans == INT_MAX) ? -1 : ans;
}

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

race.cpp: In function 'void dfs(int, int, int, int)':
race.cpp:8:22: error: 'i' was not declared in this scope
    8 |         dfs(v.first, i, dis + v.second, dep + 1);
      |                      ^