제출 #757465

#제출 시각아이디문제언어결과실행 시간메모리
757465hafo경주 (Race) (IOI11_race)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define ll long long #define ull unsigned ll #define pb push_back #define pa pair<int, int> #define pall pair<ll, int> #define fi first #define se second #define TASK "test" #define Size(x) (int) x.size() #define all(x) x.begin(), x.end() using namespace std; template<typename T1, typename T2> bool mini (T1 &a, T2 b) {if(a > b) a = b; else return 0; return 1;} template<typename T1, typename T2> bool maxi (T1 &a, T2 b) {if(a < b) a = b; else return 0; return 1;} const int MOD = 1e9 + 7; const int LOG = 20; const int maxn = 2e5 + 7; const ll oo = 1e9 + 69; int n, k, w[maxn], u, v, ed[maxn][2], dep[maxn], ans; ll f[maxn]; vector<pa> g[maxn]; unordered_map<ll, int> mp[maxn]; void dfs(int u, int par) { for(auto e:g[u]) { int v = e.fi, w = e.se; if(v == par) continue; f[v] = f[u] + w; dep[v] = dep[u] + 1; dfs(v, u); } } void dfs2(int u, int par) { mp[u][f[u]] = dep[u]; for(auto e:g[u]) { int v = e.fi; if(v == par) continue; dfs2(v, u); if(Size(mp[u]) < Size(mp[v])) { swap(mp[u], mp[v]); } for(auto e:mp[v]) { if(!mp[u].count(e.fi)) mp[u][e.fi] = e.se; else mini(mp[u][e.fi], e.se); ll rem = k + 2LL * f[u] - e.fi; if(mp[u].count(rem)) mini(ans, mp[u][e.fi] + mp[u][rem] - 2 * dep[u]); } } } int solve(int n, int k, int ed[][2], int w[]) { cin>>n>>k; for(int i = 1; i < n; i++) { cin>>ed[i][0]>>ed[i][1]; } for(int i = 1; i < n; i++) { cin>>w[i]; u = ed[i][0] + 1, v = ed[i][1] + 1; g[u].pb({v, w[i]}); g[v].pb({u, w[i]}); } ans = oo; dfs(1, 0); dfs2(1, 0); return (ans == oo ? -1:ans); }

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

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