Submission #675641

#TimeUsernameProblemLanguageResultExecution timeMemory
675641vjudge1Race (IOI11_race)C++17
Compilation error
0 ms0 KiB
#define taskname "Race" #include <bits/stdc++.h> #define int long long #define ii pair<int,int> #define ff first #define ss second using namespace std; const int maxn = 2e5 + 10; vector<ii> adj[maxn]; int sz[maxn], ban[maxn], m, ans = -1; map<int,int> mp; void DFSz(int u, int p = 0) { sz[u] = 1; for (auto [v, c]: adj[u]) if (v != p && !ban[v]) DFSz(v, u), sz[u] += sz[v]; } int getcen(int u, int need, int p = -1) { if (sz[u] <= need) return p; ii big = {0, 0}; for (auto [v, c]: adj[u]) if (v != p && !ban[v]) big = max(big, {sz[v], v}); return getcen(big.ss, need, u); } void DFS(int u, int p, int dep, int type, int dis = 1) { if (type == 0) { if (mp.count(m - dep)) ans = min(ans, dis + mp[m-dep]); } else mp[dep] = (mp.count(dep) ? min(mp[dep], dis) : dis); for (auto [v, c]: adj[u]) if (v != p && !ban[v]) DFS(v, u, dep+c, type, dis+1); } void solve(int u = 1) { DFSz(u); u = getcen(u, sz[u]/2); ban[u] = 1; mp.clear(); mp[0] = 0; for (auto [v, c]: adj[u]) if (!ban[v]) DFS(v, u, c, 0), DFS(v, u, c, 1); for (auto [v, c]: adj[u]) if (!ban[v]) solve(v); } int best_path(int N, int K, int H[][2], int L[]) { m = K; for (int i=0; i<N; i++) { int u = H[i][0], v = H[i][1], c = L[i]; u++, v++; adj[u].emplace_back(v, c); adj[v].emplace_back(u, c); } solve(); return ans; }

Compilation message (stderr)

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