Submission #373951

#TimeUsernameProblemLanguageResultExecution timeMemory
373951duchungRace (IOI11_race)C++17
Compilation error
0 ms0 KiB
#define ii pair<int , int> #include <race.h> #include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int _k , ans = 1e9; int dist[N] , depth[N]; vector<ii> adj[N]; set<ii> S[N]; void dfs(int u , int p = -1) { S[u].insert(make_pair(dist[u] , depth[u])); for (auto e : adj[u]) { int v = e.first; int w = e.second; if (v == p) continue; dist[v] = dist[u] + w; depth[v] = depth[u] + 1; dfs(v , u); if (S[u].size() < S[v].size()) swap(S[u] , S[v]); for (auto x : S[v]) { auto it = S[u].lower_bound(make_pair(_k - x.first + 2 * dist[u] , 0)); if (it != S[u].end() && it->first + x.first - 2 * dist[u] == _k) ans = min(ans , it->second + x.second - 2 * depth[u]); } for (auto x : S[v]) { S[u].insert(x); } } } int best_path(int n, int k, int H[][2], int L[]) { _k = k; for (int i = 0; i < n - 1; i++) { ++H[i][0] , ++H[i][1]; adj[H[i][0]].push_back(H[i][1], L[i]); adj[H[i][1]].push_back(H[i][0], L[i]); } dfs(1); return (ans == 1e9 ? -1 : ans); }

Compilation message (stderr)

race.cpp: In function 'int best_path(int, int, int (*)[2], int*)':
race.cpp:46:39: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(int&, int&)'
   46 |   adj[H[i][0]].push_back(H[i][1], L[i]);
      |                                       ^
In file included from /usr/include/c++/9/vector:67,
                 from /usr/include/c++/9/functional:62,
                 from /usr/include/c++/9/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/9/algorithm:71,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from race.cpp:4:
/usr/include/c++/9/bits/stl_vector.h:1184:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1184 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1184:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/9/bits/stl_vector.h:1200:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1200 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1200:7: note:   candidate expects 1 argument, 2 provided
race.cpp:47:39: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(int&, int&)'
   47 |   adj[H[i][1]].push_back(H[i][0], L[i]);
      |                                       ^
In file included from /usr/include/c++/9/vector:67,
                 from /usr/include/c++/9/functional:62,
                 from /usr/include/c++/9/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/9/algorithm:71,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from race.cpp:4:
/usr/include/c++/9/bits/stl_vector.h:1184:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1184 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1184:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/9/bits/stl_vector.h:1200:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1200 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1200:7: note:   candidate expects 1 argument, 2 provided