Submission #544624

#TimeUsernameProblemLanguageResultExecution timeMemory
544624pokmui9909Dreaming (IOI13_dreaming)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; ll N, M, L; vector<pair<ll, ll>> G[100005]; ll V1[100005]; ll D = 0, E = 0; pair<ll, ll> Dia[100005]; ll ans = 0; pair<ll, ll> path[100005]; void dfs1(ll n, ll p, ll k){ V1[n] = 1; if(D < k){ D = k; E = n; } for(auto i : G[n]){ ll nx = i.first, c = i.second; if(nx == p) continue; dfs1(nx, n, k + c); } } void dfs2(ll n, ll p, ll d){ if(n == d) return; for(auto i : G[n]){ ll nx = i.first, c = i.second; if(nx == p) continue; path[nx] = {n, c}; dfs2(nx, n, d); } } ll R[100005]; ll sum = 1e18; ll cost = 0; void track(ll n, ll s, ll i){ if(n == s) return; ll nx = path[n].first, c = path[n].second; sum = min(sum, max(R[i] - cost, cost)); cost += c; track(nx, s, i); } int travelTime(int n, int m, int l, int A[], int B[], int T[]){ N = n, M = m, L = l; for(int i = 0; i < M; i++){ ll u = A[i], v = B[i], c = T[i]; u++; v++; G[u].push_back({v, c}); G[v].push_back({u, c}); } fill(R + 1, R + N + 1, -1); for(int i = 1; i <= N; i++){ if(V1[i]) continue; D = -1; dfs1(i, -1, 0); D = -1; Dia[i].first = E; dfs1(E, -1, 0); Dia[i].second = E; R[i] = D; ans = max(ans, D); } vector<ll> X; for(int i = 1; i <= N; i++){ if(R[i] == -1) continue; dfs2(Dia[i].first, -1, Dia[i].second); sum = 1e18, cost = 0; track(Dia[i].second, Dia[i].first, i); if(Dia[i].first == Dia[i].second) sum = 0; X.push_back(sum); } sort(X.begin(), X.end(), greater<ll>()); if(X.size() >= 2){ ans = max(ans, X[0] + X[1] + L); } if(X.size() >= 3){ ans = max(ans, X[1] + X[2] + 2 * L); } return ans; }

Compilation message (stderr)

/usr/bin/ld: /tmp/cccuc73P.o: in function `main':
grader.c:(.text.startup+0xd1): undefined reference to `travelTime'
collect2: error: ld returned 1 exit status