제출 #411310

#제출 시각아이디문제언어결과실행 시간메모리
411310Mahmudul_Kabir경주 (Race) (IOI11_race)C++14
컴파일 에러
0 ms0 KiB
#include "race.h" #include "iostream" #include "algorithm" #include "iomanip" #include "vector" #include "set" #include "sstream" #include "fstream" #include "cstring" #include "stack" #include "cmath" #include "utility" #include "map" #include "bitset" #include "cassert" #include "deque" #define sp <<" " #define el <<"\n" #define S second #define F first #define all(ar) ar.begin(),ar.end() #define pb push_back #define pii pair<ll,ll> #define vvp vector<vector<pii>> using namespace std; using ll = long long; const ll mod = 1000000007; const ll si = 200005; vvp g; ll n,mxc,cnt[si],ans = mod,k; bitset<si> ded; void dfs(ll v,ll p,vector<ll> &sz){ sz[v] = 1; for(pii r: g[v]){ if(r.F == p || ded[r.F]) continue; dfs(r.F,v,sz); sz[v] += sz[r.F]; } return; } ll f_cen(ll v,ll p,ll lim,vector<ll> &sz){ for(pii r: g[v]){ if(r.F ==p || ded[r.F]) continue; if(sz[r.F] > lim) return f_cen(r.F,v,lim,sz); } return v; } void count(ll v,ll p,ll cost,ll dep,bool ad){ if(cost > k) return; mxc = max(cost,mxc); if(ad) cnt[cost] = min(cnt[cost],dep); else ans = min(ans,dep + cnt[k - cost]); for(pii r: g[v]){ if(r.F == p || ded[r.F]) continue; count(r.F,v,cost + r.S,dep+1,ad); } return; } void dec(ll v){ static vector<ll> sz(n+1); dfs(v,0,sz); ll lim = (sz[v]/2); ll cen = f_cen(v,0,lim,sz); mxc = 0; cnt[0] = 0; ded[cen] = 1; for(pii r: g[cen]){ if(ded[r.F]) continue; count(r.F,cen,r.S,1,0); count(r.F,cen,r.S,1,1); } for(ll i = 0; i <= mxc; i++) cnt[i] = mod; for(pii r: g[cen]){ if(ded[r.F]) continue; dec(r.F); } return; } int best_path(int N, int K, int H[][2], int L[]) { ios_base::sync_with_stdio(false); cin.tie(0); n = N; k = K; for(int i = 0; i < n - 1; i++){ int a = H[i][0], b = H[i][1], c = L[i]; g[a].pb({b,c}); g[b].pb({a,c}); } fill(cnt,cnt+n,mod); dec(0); ans == mod? return -1 : return ans; }

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

race.cpp: In function 'int best_path(int, int, int (*)[2], int*)':
race.cpp:104:14: error: expected primary-expression before 'return'
  104 |  ans == mod? return -1 : return ans;
      |              ^~~~~~
race.cpp:104:13: error: expected ':' before 'return'
  104 |  ans == mod? return -1 : return ans;
      |             ^~~~~~~
      |             :
race.cpp:104:14: error: expected primary-expression before 'return'
  104 |  ans == mod? return -1 : return ans;
      |              ^~~~~~
race.cpp:105:1: warning: no return statement in function returning non-void [-Wreturn-type]
  105 | }
      | ^