Submission #634353

#TimeUsernameProblemLanguageResultExecution timeMemory
634353tabrStations (IOI20_stations)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #ifdef tabr #include "library/debug.cpp" #else #define debug(...) #endif // editorial? vector<int> label(int n, int k, vector<int> x, vector<int> y) { vector<vector<int>> g(n); for (int i = 0; i < n - 1; i++) { g[x[i]].emplace_back(y[i]); g[y[i]].emplace_back(x[i]); } vector<int> depth(n), sz(n); { function<void(int, int)> Dfs = [&](int v, int p) { sz[v]++; for (int to : g[v]) { if (to == p) { continue; } depth[to] = depth[v] + 1; Dfs(to, v); sz[v] += sz[to]; } }; Dfs(0, -1); } vector<int> res(n); function<void(int, int, int, int)> Dfs = [&](int v, int p, int low, int high) { if (depth[v] % 2 == 0) { res[v] = low; low++; } else { res[v] = high - 1; high--; } for (int to : g[v]) { if (to == p) { continue; } Dfs(to, v, low, low + sz[to]); low += sz[to]; } assert(low == high); }; Dfs(0, -1, 0, n, 0); return res; } int find_next_station(int s, int t, vector<int> c) { sort(c.begin(), c.end()); if (c[0] < s) { reverse(c.begin(), c.end()); for (int v : c) { if (v <= t && t < s) { return v; } } } else { for (int v : c) { if (s < t && t <= v) { return v; } } } return c.back(); } #ifdef tabr int main() { ios::sync_with_stdio(false); cin.tie(0); return 0; } #endif

Compilation message (stderr)

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:50:23: error: no match for call to '(std::function<void(int, int, int, int)>) (int, int, int, int&, int)'
   50 |     Dfs(0, -1, 0, n, 0);
      |                       ^
In file included from /usr/include/c++/10/functional:59,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from stations.cpp:1:
/usr/include/c++/10/bits/std_function.h:617:5: note: candidate: '_Res std::function<_Res(_ArgTypes ...)>::operator()(_ArgTypes ...) const [with _Res = void; _ArgTypes = {int, int, int, int}]'
  617 |     function<_Res(_ArgTypes...)>::
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/std_function.h:617:5: note:   candidate expects 4 arguments, 5 provided