Submission #1046148

#TimeUsernameProblemLanguageResultExecution timeMemory
1046148I_FloPPed21Race (IOI11_race)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; map<long long,int> mp[200005] ; vector<int> adj[200005]; long long h[200005][2] , v[200005],target = 0 ,sum[200005],height[200005],ans = 1e9; void precomp(int nod , int p , int hd) { sum[nod] += v[nod]; height[nod] = hd ; for ( auto u : adj[nod] ) { if ( u != p ) { sum[u] += sum[nod]; precomp(u,nod,hd + 1); } } } void small(int nod ,int p ) { int real_target = target + 2 * sum[nod]; mp[nod][sum[nod]] = height[nod]; for ( auto u : adj[nod] ) { if ( u != p ) { small(u,nod); } } for ( auto u : adj[nod] ) { if( u != p ) { if( mp[u].size() > mp[nod].size()) swap(mp[nod],mp[u]); for ( auto u : mp[u] ) { long long real = target - u.second ; if ( mp[nod][real] != 0 ) { ans = min ( ans , u.first + mp[nod][real] ); } if( mp[nod][u.first] == 0 ) mp[nod][u.first] = u .second; else mp[nod][u.first] = min(mp[nod][u.first],u.second); } } } } int best_path(int n , int k , long long h[200005][2] , long long costs [200005] ) { target =k ; for ( int i = 1; i < n ; i ++ ) { adj[h[i][1]].push_back(h[i][0]); adj[h[i][0]].push_back(h[i][1]); } for ( int i = 1; i <= n ; i ++) v[i] =costs[i]; precomp(1,0,1); small(1,0); if( ans == 1e9) return -1; else return ans ; }

Compilation message (stderr)

race.cpp: In function 'void small(int, int)':
race.cpp:24:9: warning: unused variable 'real_target' [-Wunused-variable]
   24 |     int real_target = target + 2 * sum[nod];
      |         ^~~~~~~~~~~
race.cpp: In function 'int best_path(int, int, long long int (*)[2], long long int*)':
race.cpp:67:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   67 |     for ( int i = 1; i <= n ; i ++)
      |     ^~~
race.cpp:70:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   70 |         precomp(1,0,1);
      |         ^~~~~~~
/usr/bin/ld: /tmp/ccXO5goZ.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