제출 #42430

#제출 시각아이디문제언어결과실행 시간메모리
42430comfile경주 (Race) (IOI11_race)C++11
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define mp make_pair #define pb push_back using namespace std; const int MN = 200010; int n,k,ans,sz[MN],dead[MN]; vector<pair<int,int> > g[MN]; void get_sz(int cur,int prev){ sz[cur] = 1; for(auto &x : g[cur]) if(x.first!=prev && !dead[x.first]){ get_sz(x.first,cur); sz[cur] += sz[x.first]; } } int dfs(int cur,int prev,int tot){ for(auto &x : g[cur]) if(x.first!=prev && !dead[x.first]){ if(sz[x.first]>(tot/2)) return dfs(x.first,cur,tot); } return cur; } int one(int root){ get_sz(root,-1); return dfs(root,-1,sz[root]); } void rec(int start){ int c = one(start); dead[c] = 1; for(auto &x : g[c]) if(!dead[x.first]) rec(x.first); map<int,int> cnt; function<void (int,int,int,int,int)> add_cnt = [&](int cur,int prev,int d,int st,int add){ if(d>k) return; cnt[d] = cnt[d]?min(cnt[d],st):st; for(auto &x : g[cur]) if(x.first!=prev && !dead[x.first]){ add_cnt(x.first,cur,d+x.second,st+1,add); } }; function<void (int,int,int,int)> calc = [&](int cur,int prev,int d,int st){ if(d>k) return; if(k!=d && cnt[k-d]) ans = min(ans,st+cnt[k-d]); for(auto &x: g[cur]) if(x.first!=prev && !dead[x.first]){ calc(x.first,cur,d+x.second,st+1); } }; add_cnt(c,-1,0,0,1); if(cnt[k]) ans = min(ans,cnt[k]); cnt.clear(); for(auto &x : g[c]) if(!dead[x.first]){ calc(x.first,c,x.second,1); add_cnt(x.first,c,x.second,1,1); } dead[c] = 0; } int main(){ ans = MN; ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> k; for(int i=1;i<n;i++){ int a,b,c; cin >> a >> b >> c; g[a].pb(mp(b,c)); g[b].pb(mp(a,c)); } rec(0); if(ans>=MN) ans = -1; cout << ans << '\n'; return 0; }

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

/tmp/cc5XYko0.o: In function `main':
race.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cc2efuJ0.o:grader.cpp:(.text.startup+0x0): first defined here
/tmp/cc2efuJ0.o: In function `main':
grader.cpp:(.text.startup+0x20): undefined reference to `best_path(int, int, int (*) [2], int*)'
collect2: error: ld returned 1 exit status