Submission #413687

#TimeUsernameProblemLanguageResultExecution timeMemory
413687Mahmudul_KabirRace (IOI11_race)C++14
Compilation error
0 ms0 KiB
#include "race.h" #include <bits/stdc++.h> #define sp <<" " #define el <<"\n" #define S second #define F first #define pb push_back #define all(ar) ar.begin(),ar.end() #define pii pair<ll,ll> using namespace std; using ll = long long; using ld = long double; const ll mxr = 200005; const ll big = 2000000999; ll n,k,path[1000011],mac,ans = big; vector<vector<pii>> g; bitset<mxr> ded; void dfs(int v,int p){ sz[v] = 1; for(pii r: g[v]){ if(r.F == p || ded[r.F]) continue; dfs(r.F,v); sz[v] += sz[r.F]; } return; } int fcen(int v,int p,int lim){ for(pii r: g[v]){ if(r.F == p || ded[r.F]) continue; if(sz[r.F] > lim) return fcen(r.F,v,lim); } return v; } void fil(int v,int p,int cost,int dep,unordered_map<int,int> &dis){ if(cost > k) return; ans = min(ans,dep + path[k - cost]); dis[cost] = dis.count(cost) ? min(dis[cost],dep) : dep; for(pii r: g[v]){ if(r.F == p || ded[r.F]) continue; fil(r.F,v,cost + r.S,dep+1,dis); } return; } void decompose(int v){ dfs(v,-1); int lim = (sz[v]/2); int cen = fcen(v,-1,lim); ded[cen] = 1; unordered_set<int> cum; for(pii r: g[cen]){ if(ded[r.F]) continue; unordered_map<int,int> dis; fil(r.F,cen,r.S,1,dis); for(pii x: dis){ cum.insert(x.F); path[x.F] = x.S; } } ans = min(ans,path[k]); for(int i : cum) path[i] = big; for(pii r: g[cen]){ if(!ded[r.F]) decompose(r.F); } } int best_path(int N, int K, int H[][2], int L[]) { n = N; k = K; g.assign(n,{}); for(int i = 1; i < n; i++){ int a = H[i-1][0], b = H[i-1][1], c = L[i-1]; g[a].pb({b,c}); g[b].pb({a,c}); } for(int i = 0; i <= 1000010; i++) path[i] = big; decompose(0); return ans == big ? -1 : ans; }

Compilation message (stderr)

race.cpp: In function 'void dfs(int, int)':
race.cpp:26:3: error: 'sz' was not declared in this scope; did you mean 'sp'?
   26 |   sz[v] = 1;
      |   ^~
      |   sp
race.cpp: In function 'int fcen(int, int, int)':
race.cpp:38:8: error: 'sz' was not declared in this scope; did you mean 'sp'?
   38 |     if(sz[r.F] > lim) return fcen(r.F,v,lim);
      |        ^~
      |        sp
race.cpp: In function 'void decompose(int)':
race.cpp:56:14: error: 'sz' was not declared in this scope; did you mean 'sp'?
   56 |   int lim = (sz[v]/2);
      |              ^~
      |              sp