Submission #674252

#TimeUsernameProblemLanguageResultExecution timeMemory
674252Megumin2006Race (IOI11_race)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define ed '\n' #define pb push_back #define ii pair<ll,ll> #define fi first #define se second using namespace std; const ll N = 2e5 + 10; ii lazy[N]; vector<ii> g[N]; ll n, k, ans = 1e18; map<ll, ll> f[N]; void Merge(ll u, ll v) { if (f[u].size() < f[v].size()) { swap(lazy[u], lazy[v]); f[u].swap(f[v]); } for(pair<ll, ll> tmp: f[v]) { ll num = tmp.fi + lazy[v].fi; ll Min = tmp.se + lazy[v].se; auto t = f[u].find(k - num - lazy[u].fi); if (t != f[u].end()) { if (t->se + Min + lazy[u].se < ans) { ans = t->se + Min + lazy[u].se; } } if (f[u][num - lazy[u].fi] == 0) f[u][num - lazy[u].fi] = Min - lazy[u].se; else { if (Min - lazy[u].se < f[u][num - lazy[u].fi]) { f[u][num - lazy[u].fi] = Min - lazy[u].se; } } } } void dfs(ll u, ll p, ll val) { f[u][0] = 0; for(ii &e: g[u]) if (e.fi != p) { dfs(e.fi, u, e.se); Merge(u, e.fi); } lazy[u].fi += val; lazy[u].se ++; } ll best_path(ll N, ll K, ll H[][2], ll L[]) { n = N, k = K; for(ll i=0;i<n-1;i++) { g[H[i][0]].pb({H[i][1],L[i]}); g[H[i][1]].pb({H[i][0],L[i]}); } dfs(0, -1, 0); if (ans == 1e18) ans = -1; return ans; }

Compilation message (stderr)

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