Submission #945015

#TimeUsernameProblemLanguageResultExecution timeMemory
945015mannshah1211Race (IOI11_race)C++17
Compilation error
0 ms0 KiB
#include "race.h" #include "bits/stdc++.h" int best_path(int N, int K, int H[][2], int L[]) { std::vector<std::vector<std::pair<int, int>>> adj(N); for (int i = 0; i < N - 1; i++) { adj[H[i][0]].push_back(std::make_pair(H[i][1], L[i])); adj[H[i][1]].push_back(std::make_pair(H[i][0], L[i])); } std::vector<long long> sum(N); std::vector<int> dep(N); dep[0] = 1; auto Dfs = [&](int u, int p, auto&& Dfs) -> void { for (auto& [v, w] : adj[u]) { if (v == p) continue; sum[v] = sum[u] + w; dep[v] = dep[u] + 1; Dfs(v, u, Dfs); } }; Dfs(0, -1, Dfs); int mn = N + 1; auto small_to_large = [&](int u, int p, auto&& small_to_large) -> std::map<long long, int> { long long need = K + (2 * sum[u]); std::map<long long, int> here; here[sum[u]] = dep[u]; for (auto& [v, w] : adj[u]) { if (v == p) continue; std::map<long long, int> child = small_to_large(v, u, small_to_large); if (here.size() < child.size()) std::swap(here, child); for (auto& [s, depth] : child) { if (here[need - s] != 0) { mn = std::min(mn, here[need - s] + depth - (2 * dep[u])); } } for (auto& [s, depth] : child) { if (here[s] == 0) here[s] = depth; else here[s] = min(here[s], depth); } } return here; }; small_to_large(0, -1, small_to_large); if (mn == N + 1) return -1; else return mn; }

Compilation message (stderr)

race.cpp: In instantiation of 'best_path(int, int, int (*)[2], int*)::<lambda(int, int, auto:24&&)> [with auto:24 = best_path(int, int, int (*)[2], int*)::<lambda(int, int, auto:24&&)>&]':
race.cpp:43:40:   required from here
race.cpp:38:24: error: 'min' was not declared in this scope; did you mean 'std::min'?
   38 |      else here[s] = min(here[s], depth);
      |                     ~~~^~~~~~~~~~~~~~~~
      |                     std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from race.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~