Submission #502086

#TimeUsernameProblemLanguageResultExecution timeMemory
502086mbfibatRace (IOI11_race)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> ii; vector<ii> adj[200001]; int h[200001], d[200001]; map<int, int> mp[200001]; int dfs(int u, int p, int k) { int ans = 1e9; mp[u][d[u]] = h[u]; for (auto& [v, w] : adj[u]) { if (v == p) continue; h[v] = h[u] + 1; d[v] = d[u] + w; ans = min(ans, dfs(v, u, k)); if (mp[v].size() > mp[u].size()) swap(mp[v], mp[u]); for (auto& [dis, height] : mp[v]) if (mp[u].count(k - (dis - d[u]) + d[u])) ans = min(ans, mp[u][k - (dis - d[u]) + d[u]] + height - 2 * h[u]); for (auto& [dis, height] : mp[v]) { if (!mp[u].count(dis)) mp[u][dis] = height; else mp[u][dis] = min(mp[u][dis], height); } mp[v].clear(); } return ans; } int best_path(int n, int k, int **h, int *l) { for (int i = 0; i < n - 1; i++) { int u = h[i][0], v = h[i][1], w = l[i]; adj[u].push_back(ii(v, w)); adj[v].push_back(ii(u, w)); } int ans = dfs(0, -1, k); if (ans == 1e9) ans = -1; return ans; }

Compilation message (stderr)

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