Submission #853638

#TimeUsernameProblemLanguageResultExecution timeMemory
853638DzadzoRace (IOI11_race)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define ll long long #define int ll #define pb push_back #define S second #define F first #define pii pair<int,int> #define vi vector <int> #define vvi vector <vi> #define vvvi vector <vvi> #define vp vector <pii> #define vvp vector <vp> #define vb vector <bool> #define vvb vector <vb>; #define INF INT_MAX #define MOD 998244353 #define MAXN 200000 #pragma GCC optimize("O3,unroll-loops") using namespace std; vvp adj(MAXN); vb deleted(MAXN); vi s(MAXN); int k; void up(int v,int p){ if (deleted[v])s[v]=0;else{ s[v]=1; for (auto& [to,w]:adj[v]){ if (to==p)continue; up(to,v); s[v]+=s[to]; } } } int find(int v,int p,int n){ for (auto& [to,w]:adj[v]) if (to!=p && !deleted[to] && s[to]>n/2) return find(to,v,n); return v; } vi cnt(1000001,INF); int ans=INF; void add(int v,int p,int dist,int depth){ if (dist>k)return; cnt[dist]=min(cnt[dist],depth); for (auto& [to,w]:adj[v]) if (to!=p && !deleted[to]) add(to,v,dist+w,depth+1); } void calc(int v,int p,int dist,int depth){ if (dist>k)return; ans=min(ans,depth+cnt[k-dist]); // cout<<v<<" "<<p<<" "<<dist<<" "<<depth<<" "<<cnt[k-dist]<<"\n"; for (auto& [to,w]:adj[v]) if (to!=p && !deleted[to]) calc(to,v,dist+w,depth+1); } void remove(int v,int p,int dist){ if (dist>k)return; cnt[dist]=INF; for (auto& [to,w]:adj[v]) if (to!=p && !deleted[to]) remove(to,v,dist+w); } void build(int v){ up(v,-1); int c=find(v,-1,s[v]); cnt[0]=0; for (auto& [to,w]:adj[c]){ if (!deleted[to]){ add(to,c,w,1); } } for (auto& [to,w]:adj[c]){ if (!deleted[to]){ calc(to,c,w,1); } } for (auto& [to,w]:adj[c]){ if (!deleted[to]){ remove(to,c,w); } } deleted[c]=true; for (auto [to,w]:adj[c])if (!deleted[to])build(to); } int32_t best_path(int N, int K, int H[][2], int L[]){ k=K; for (int i=0;i<N-1;i++){ adj[H[i][0]].pb({H[i][1],L[i]}); adj[H[i][1]].pb({H[i][0],L[i]}); } build(0); if (ans==INF)return -1; return ans; }

Compilation message (stderr)

race.cpp: In function 'void up(long long int, long long int)':
race.cpp:27:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   27 |   for (auto& [to,w]:adj[v]){
      |              ^
race.cpp: In function 'long long int find(long long int, long long int, long long int)':
race.cpp:35:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   35 |  for (auto& [to,w]:adj[v])
      |             ^
race.cpp: In function 'void add(long long int, long long int, long long int, long long int)':
race.cpp:45:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   45 |  for (auto& [to,w]:adj[v])
      |             ^
race.cpp: In function 'void calc(long long int, long long int, long long int, long long int)':
race.cpp:53:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   53 |  for (auto& [to,w]:adj[v])
      |             ^
race.cpp: In function 'void remove(long long int, long long int, long long int)':
race.cpp:60:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   60 |  for (auto& [to,w]:adj[v])
      |             ^
race.cpp: In function 'void build(long long int)':
race.cpp:68:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   68 |  for (auto& [to,w]:adj[c]){
      |             ^
race.cpp:73:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   73 |  for (auto& [to,w]:adj[c]){
      |             ^
race.cpp:78:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   78 |  for (auto& [to,w]:adj[c]){
      |             ^
race.cpp:84:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   84 |  for (auto [to,w]:adj[c])if (!deleted[to])build(to);
      |            ^
/usr/bin/ld: /tmp/ccJ9t4Lz.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