Submission #1087167

#TimeUsernameProblemLanguageResultExecution timeMemory
1087167MateiKing80Dreaming (IOI13_dreaming)C++14
Compilation error
0 ms0 KiB
#include "dreaming.h" #include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; #define all(a) (a).begin(), (a).end() #define pb push_back #define fr first #define sc second using ll = long long; #define int ll vector<int> a, b, t, dp; vector<pii> vec[100000]; vector<bool> f; int dfs1(int nod, int papa) { f[nod] = true; int doi = 0; for(auto i : vec[nod]) if(i.fr != papa) { dfs1(i.fr, nod); if(dp[nod] <= i.sc + dp[i.fr]) doi = dp[nod], dp[nod] = i.sc + dp[i.fr]; else doi = max(doi, i.sc + dp[i.fr]); } return dp[nod] + doi; } int dfs2(int nod, int papa, int desus = 0) { int ans = desus, doi = 0; for(auto i : vec[nod]) if(i.fr != papa) { if(ans <= i.sc + dp[i.fr]) doi = ans, ans = i.sc + dp[i.fr]; else doi = max(doi, i.sc + dp[i.fr]); } int rasp = ans; for(auto i : vec[nod]) if(i.fr != papa) { if(ans == i.sc + dp[i.fr]) rasp = min(rasp, dfs2(i.fr, nod, doi + i.sc)); else rasp = min(rasp, dfs2(i.fr, nod, ans + i.sc)); } return rasp; } int travelTime(int n, int m, int l, int A[], int B[], int T[]) { for(int i = 0; i < m; i ++) a.pb(A[i]); for(int i = 0; i < m; i ++) b.pb(B[i]); for(int i = 0; i < m; i ++) t.pb(T[i]); for(int i = 0; i < m; i ++) vec[a[i]].pb({b[i], t[i]}), vec[b[i]].pb({a[i], t[i]}); f.resize(n, false); dp.resize(n, 0); vector<int> vals, diams; for(int i = 0; i < n; i ++) if(!f[i]) diams.pb(dfs1(i, -1)), vals.pb(dfs2(i, -1)); sort(all(vals), [&](int a, int b){return a > b;}); sort(all(diams), [&](int a, int b){return a > b;}); int ans = 0; if(vals.size() >= 2) ans = vals[0] + vals[1] + l; if(vals.size() >= 3) ans = max(ans, vals[1] + vals[2] + 2 * l); ans = max(ans, diams[0]); return ans; } /* int main() { int N, M, L, A[5000], B[5000], T[5000]; cin >> N >> M >> L; for(int i = 0; i < M; i ++) cin >> A[i]; for(int i = 0; i < M; i ++) cin >> B[i]; for(int i = 0; i < M; i ++) cin >> T[i]; cout << travelTime(N, M, L, A, B, T); } */

Compilation message (stderr)

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