제출 #945023

#제출 시각아이디문제언어결과실행 시간메모리
945023mannshah1211경주 (Race) (IOI11_race)C++17
컴파일 에러
0 ms0 KiB
#include "race.h" #include "bits/stdc++.h" long long best_path(long long N, long long K, long long H[][2], long long L[]) { std::vector<std::vector<std::pair<long long, long long>>> adj(N); for (long long i = 0; i < N - 1; i++) { adj[H[i][0]].push_back(std::make_pair(H[i][1], 1ll * L[i])); adj[H[i][1]].push_back(std::make_pair(H[i][0], 1ll * L[i])); } std::vector<long long> sum(N); std::vector<long long> dep(N); dep[0] = 1; auto Dfs = [&](long long u, long long p, auto&& Dfs) -> void { for (auto& [v, w] : adj[u]) { if (v == p) continue; sum[v] = sum[u] + w; dep[v] = dep[u] + 1; Dfs(v, u, Dfs); } }; Dfs(0, -1, Dfs); long long mn = N + 1; auto small_to_large = [&](long long u, long long p, auto&& small_to_large) -> std::map<long long, long long> { long long need = K + (2 * sum[u]); std::map<long long, long long> here; here[sum[u]] = dep[u]; for (auto& [v, w] : adj[u]) { if (v == p) continue; std::map<long long, long long> child = small_to_large(v, u, small_to_large); if (here.size() < child.size()) std::swap(here, child); for (auto& [s, depth] : child) { if (here[need - s] != 0) { mn = std::min(mn, here[need - s] + depth - (2 * dep[u])); } } for (auto& [s, depth] : child) { if (here[s] == 0) here[s] = depth; else here[s] = std::min(here[s], depth); } } return here; }; small_to_large(0, -1, small_to_large); if (mn == N + 1) return -1; else return (int) mn; }

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

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