제출 #703326

#제출 시각아이디문제언어결과실행 시간메모리
703326Chal1shkan경주 (Race) (IOI11_race)C++14
컴파일 에러
0 ms0 KiB
# include <bits/stdc++.h> # include "race.h" # define pb push_back # define ff first # define ss second # define nl "\n" # define sz(x) ((int)(x).size()) # define deb(x) cerr << #x << " = " << x << endl; # define pll pair <ll, ll> # define pii pair <int, int> typedef long long ll; typedef unsigned long long ull; typedef long double ld; const ll maxn = 2e5 + 25; const ll inf = 2e9 + 0; const ll mod = 998244353; const ll dx[] = {-1, 1, 0, 0}; const ll dy[] = {0, 0, -1, 1}; using namespace std; ll n, k, ans; vector <pii> g[maxn]; ll sz[maxn]; bool used[maxn]; ll mn[maxn]; void dfs_calc (ll v, ll pa) { sz[v] = 1; for (pii i : g[v]) { ll to = i.ff, w = i.ss; if (to == pa || used[to]) continue; dfs_calc(to, v); sz[v] += sz[to]; } } ll find_c (ll v, ll pa, ll siz) { for (pii i : g[v]) { ll to = i.ff, w = i.ss; if (to == pa || used[to]) continue; if (sz[to] + sz[to] > siz) { return find_c(to, v, siz); } } return v; } void dfs_add (ll v, ll pa, ll d1, ll d2) { mn[d1] = min(mn[d1], d2); for (pii i : g[v]) { ll to = i.ff, w = i.ss; if (to == pa || used[to]) continue; dfs_add(to, v, d1 + w, d2 + 1); } } void dfs_del (ll v, ll pa, ll d1, ll d2) { mn[d1] = inf; for (pii i : g[v]) { ll to = i.ff, w = i.ss; if (to == pa || used[to]) continue; dfs_del(to, v, d1 + w, d2 + 1); } } void dfs_ans (ll v, ll pa, ll d1, ll d2) { if (d1 > k) return; ans = min(ans, d2 + mn[k - d1]); for (pii i : g[v]) { ll to = i.ff, w = i.ss; if (to == pa || used[to]) continue; dfs_ans(to, v, d1 + w, d2 + 1); } } void centroid (ll v) { dfs_calc(v, v); v = find_c(v, v, sz[v]); mn[0] = 0; for (pii i : g[v]) { ll to = i.ff, w = i.ss; if (used[to]) continue; dfs_ans(to, v, w, 1); dfs_add(to, v, w, 1); } mn[0] = inf; for (pii i : g[v]) { ll to = i.ff, w = i.ss; if (used[to]) continue; dfs_del(to, v, w, 1); } used[v] = 1; for (pii i : g[v]) { ll to = i.ff, w = i.ss; if (used[to]) continue; centroid(to); } } ll best_path(ll N, ll K, ll H[][2], ll L[]) { n = N, k = K, ans = inf; for(ll i = 0; i < n - 1; ++i){ g[H[i][0] + 1].pb({H[i][1] + 1, L[i]}); g[H[i][1] + 1].pb({H[i][0] + 1, L[i]}); } for (ll i = 1; i < n; ++i) mn[i] = inf; centroid(1); return (ans == inf ? -1 : ans); }

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

race.cpp: In function 'void dfs_calc(ll, ll)':
race.cpp:36:23: warning: unused variable 'w' [-Wunused-variable]
   36 |         ll to = i.ff, w = i.ss;
      |                       ^
race.cpp: In function 'll find_c(ll, ll, ll)':
race.cpp:47:23: warning: unused variable 'w' [-Wunused-variable]
   47 |         ll to = i.ff, w = i.ss;
      |                       ^
race.cpp: In function 'void centroid(ll)':
race.cpp:113:23: warning: unused variable 'w' [-Wunused-variable]
  113 |         ll to = i.ff, w = i.ss;
      |                       ^
/usr/bin/ld: /tmp/cc50W2YS.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