Submission #1263427

#TimeUsernameProblemLanguageResultExecution timeMemory
1263427tkhoi13Dreaming (IOI13_dreaming)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> // #include "dreaming.h" #define REP(i, n) for (int i = 0, _b = (n); i < _b; i++) #define FOR(i, a, b) for (int i = a, _b = (b); i <= _b; i++) #define pb push_back #define szx(x) (int)(x).size() #define all(x) (x).begin(), (x).end() using namespace std; #define pii pair<int, int> vector<pii> adj[100000]; vector<int> dis(100000, -1); int ans = 0; int mx = 0, d = 0; int par[100000]; void dfs(int u, int p = -1) { if (mx < dis[u]) mx = dis[u], d = u; par[u] = p; for (auto& [v, w] : adj[u]) { if (v != p) { dis[v] = dis[u] + w; dfs(v, u); } } } int travelTime(int N, int M, int L, int A[], int B[], int T[]) { REP(i, M) { adj[A[i]].pb({B[i], T[i]}); adj[B[i]].pb({A[i], T[i]}); } vector<int> half; // cout << dis[0] << REP(i, N) if (dis[i] == -1) { mx = -1; d = 0; dis[i] = 0; dfs(i); int d1 = d; mx = -1, d = 0; dis[d1] = 0; dfs(d1); int d2 = d; ans = max(ans, mx); int ans1 = INT_MAX; for (int u = d2; u != -1; u = par[u]) ans1 = min(max(dis[u], mx - dis[u]), ans1); // for (int u = d2; u != -1; u = par[u]) { cout << u << ' '; }; // cout << endl; half.pb(ans1); // cout << ans1 << ' '; } sort(all(half), greater<int>()); FOR(i, 1, szx(half) - 1) { ans = max(ans, half[0] + i * L + half[i]); } // for (int i : half) cout << i << ' '; // cout << endl; return ans; } // int main() { // int N = 12; // int M = 8; // int L = 2; // int A[]{0, 8, 2, 5, 5, 1, 1, 10}; // int B[]{8, 2, 7, 11, 1, 3, 9, 6}; // int T[]{4, 2, 4, 3, 7, 1, 5, 3}; // int x = travelTime(N, M, L, A, B, T); // // REP(i, N) { cout << dis[i] << ' '; } // cout << x; // }

Compilation message (stderr)

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