Submission #865452

#TimeUsernameProblemLanguageResultExecution timeMemory
865452tamir1Race (IOI11_race)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #define ll long long #define pp pair<ll,ll> #define f first #define s second using namespace std; ll N,K,L[200001],i,a,b,ans=1e9,sz[200001]; pp H[200001]; bitset<200001> mark; map<ll,ll> mp; vector<pp> G[200001]; ll getsize(ll a,ll p=-1){ sz[a]=1; for(pp i:G[a]){ if(p!=i.f && !mark[i.f]) sz[a]+=getsize(i.f,a); } return sz[a]; } ll centroid(ll a,ll p,ll n){ for(pp i:G[a]){ if(p!=i.f && sz[i.f]>n/2 && !mark[i.f]) return centroid(i.f,a,n); } return a; } void dfs(ll a,ll p,ll dist,ll len,bool key){ if(dist>K) return; if(dist==K){ ans=min(ans,len); return; } if(key){ if(mp[K-dist]) ans=min(ans,len+mp[K-dist]); } else{ if(!mp[dist]) mp[dist]=len; else mp[dist]=min(mp[dist],len); } for(pp i:G[a]){ if(p!=i.f && !mark[i.f]){ dfs(i.f,a,dist+i.s,len+1,key); } } } void solve(ll a=1){ ll n,cnt; n=getsize(a); cnt=centroid(a,0,n); mark[cnt]=1; mp.clear(); for(pp i:G[cnt]){ if(!mark[i.f]){ dfs(i.f,cnt,i.s,1,1); dfs(i.f,cnt,i.s,1,0); } } for(pp i:G[cnt]){ if(!mark[i.f]) solve(i.f); } } int main(){ cin >> N >> K; for(i=1;i<N;i++){ cin >> H[i].f >> H[i].s; } for(i=1;i<N;i++){ cin >> L[i]; } for(i=1;i<N;i++){ a=H[i].f+1; b=H[i].s+1; G[a].push_back({b,L[i]}); G[b].push_back({a,L[i]}); } solve(); if(ans!=1e9) cout << ans; else cout << -1; }

Compilation message (stderr)

/usr/bin/ld: /tmp/cceImWIg.o: in function `main':
race.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc3rj21i.o:grader.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cc3rj21i.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