Submission #1088073

#TimeUsernameProblemLanguageResultExecution timeMemory
1088073quan606303Race (IOI11_race)C++14
Compilation error
0 ms0 KiB
///0-0 : what is your motivation, quan606303? ///quan606303 : Hutao /*idea : */ #include <bits/stdc++.h> #define int long long #define ll long long #define INTMAX INT_MAX #define INTMIN INT_MIN #define LONGMAX LLONG_MAX #define LONGMIN LLONG_MIN #define fi first #define se second #define memfull(a,b) memset(a,b,sizeof(a)); #define endl '\n' #define file(a) freopen(a".inp","r",stdin); freopen(a".out","w",stdout); using namespace std; const int MOD=1e9+7; const int maxn=2e5+7; const int maxk=1e6+7; int n,k,del[maxn],child[maxn]; vector<pair<int,int> > adj[maxn]; int ans=1e15,cnt[maxk]; const int inf=1e15; void dfs(int u,int p) { child[u]=1; for (auto v:adj[u]) { if (v.fi!=p&&!del[v.fi]) { dfs(v.fi,u); child[u]+=child[v.fi]; } } } int find_centroid(int u,int p,int N) { for (auto v:adj[u]) { if (v.fi!=p&&!del[v.fi]&&child[v.fi]>N/2) { return find_centroid(v.fi,u,N); } } return u; } int mxdis=0; void cal(int u,int p,bool filling,int distance,int depth) { if (distance>k)return ; mxdis=max(mxdis,distance); if (filling)cnt[distance]=min(cnt[distance],depth); else { ans=min(ans,cnt[k-distance]+depth); // cout<<u<<" "<<distance<<" "<<depth<<" "<<cnt[k-distance]<<endl; } for (auto v:adj[u]) { if (!del[v.fi]&&v.fi!=p)cal(v.fi,u,filling,distance+v.se,depth+1); } } void solve(int u) { dfs(u,0); int N=child[u]; int root=find_centroid(u,0,N); // for (int i=1;i<=n;i++)cout<<child[i]<<endl; del[root]=true; mxdis=0; for (auto v:adj[root]) { if (!del[v.fi]) { // cout<<v.fi<<" "<<root<<" "<<v.se<<" "<<1<<endl; cal(v.fi,root,false,v.se,1); cal(v.fi,root,true,v.se,1); } } fill(cnt+1,cnt+1+mxdis,inf); for (auto v:adj[root]) { if (!del[v.fi])solve(v.fi); } } int32_t best_path(int N, int K, int H[][2], int L[]){ // file(""); n=N; k=K; for (int i=1;i<n;i++) { int x = H[i][0]; int y = H[i][1]; int w = L[i]; x++; y++; adj[x].push_back({y,w}); adj[y].push_back({x,w}); } for (int i=1;i<maxk;i++)cnt[i]=inf; solve(1); if (ans==inf)return -1; else return ans; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccp1ZD13.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