Submission #805164

#TimeUsernameProblemLanguageResultExecution timeMemory
805164Halym2007Tropical Garden (IOI11_garden)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back const int MAX_N = 1005; vector <int> v[MAX_N]; int k, jog, par[MAX_N], cost[MAX_N][MAX_N]; map <int, int> m; void dfs1 (int x, int pr) { par[x] = pr; for (int i : v[x]) { if (i != pr) { dfs1 (i, x); } } } void dfs2 (int x, int pr, int edges, int baha) { if (baha > k) return; m[baha] = edges; for (int i : v[x]) { if (i != pr and i != par[x]) { dfs2 (i, pr, edges + 1, baha + cost[x][i]); } } } void dfs (int x, int pr, int baha, int edges) { if (baha > k or pr == -1) { return; } if ((baha + cost[x][par[x]]) == k) { if (jog == -1) jog = edges + 1; else jog = min (jog, edges + 1); return; } m.clear(); dfs2 (pr, x, 0, 0); int jp = baha + cost[x][par[x]]; if (m.find (k - jp) != m.end()) { if (jog == -1) jog = edges + m[k - jp] + 1; else jog = min (jog, edges + m[k - jp] + 1); } dfs (pr, par[pr], baha + cost[x][par[x]], edges + 1); } int best_path(int N, int K, int H[][2], int L[]) { jog = -1; k = K; for (int i = 0; i < N - 1 ; ++i) { v[H[i][0]].pb (H[i][1]); v[H[i][1]].pb (H[i][0]); cost[H[i][0]][H[i][1]] = L[i]; cost[H[i][1]][H[i][0]] = L[i]; } dfs1 (1, -1); for (int i = 0; i < N; ++i) { dfs (i, par[i], 0, 0); } return jog; }

Compilation message (stderr)

/usr/bin/ld: /tmp/cct4Sc6P.o: in function `main':
grader.cpp:(.text.startup+0x3f): undefined reference to `count_routes(int, int, int, int (*) [2], int, int*)'
collect2: error: ld returned 1 exit status