Submission #362405

#TimeUsernameProblemLanguageResultExecution timeMemory
362405knightron0Traffic (IOI10_traffic)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define fr first #define sc second #define clr(a, x) memset(a, x, sizeof(a)) #define dbg(x) cout<<"("<<#x<<"): "<<x<<endl; #define printvector(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout<<*it<<" "; cout<<endl; #define all(v) v.begin(), v.end() #define lcm(a, b) (a * b)/__gcd(a, b) #define int long long int #define printvecpairs(vec) for(auto it: vec) cout<<it.fr<<' '<<it.sc<<endl; #define endl '\n' #define float long double const int MOD = 1e9 + 7; const int INF = 2e15; const int MAXN = 1e5 + 5; vector<int> adj[MAXN]; int value[MAXN]; int sz[MAXN] = {0}; int dfs(int s, int p){ int ans = value[s]; for(auto v: adj[s]){ if(v ==p) continue; ans += dfs(v, s); } sz[s] = ans; return ans; } int ans = INT_MAX; void dfs2(int s, int p, int last){ int mx = last; int sum = last; for(auto v: adj[s]){ if(v==p) continue; sum += sz[v]; mx = max(mx, sz[v]); } ans = min(ans, mx); for(auto v: adj[s]){ if(v==p) continue; int newlast = sum-sz[v]; newlast += value[s]; dfs2(v, s, newlast); } } int LocateCentre(int n, int p[], int d[], int s[]) { sz[0] = 0; value[0]= 0; for(int i= 0;i<n-1;i++){ d[i]++; s[i]++; adj[d[i]].pb(s[i]); adj[s[i]].pb(d[i]); } for(int i= 0;i<n;i++){ value[i+1] = p[i]; } dfs(1, -1); dfs2(1, 0, 0); return ans; } // signed main() { // ios_base::sync_with_stdio(false); // cin.tie(NULL); // #ifdef LOCAL // freopen("input.txt", "r", stdin); // #endif // int n; // cin>>n; // int val[n]; // for(int i= 0;i<n;i++){ // cin>>val[i]; // } // int a[n], b[n]; // for(int i= 0;i<n-1;i++){ // cin>>a[i]>>b[i]; // } // LocateCentre(n, val, a, b); // return 0; // }

Compilation message (stderr)

/tmp/ccaDkyx3.o: In function `main':
grader.cpp:(.text.startup+0xd9): undefined reference to `LocateCentre(int, int*, int*, int*)'
collect2: error: ld returned 1 exit status