Submission #519006

#TimeUsernameProblemLanguageResultExecution timeMemory
519006fabijan_cikacRace (IOI11_race)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pp; const int MAXN = 2 * 1e5 + 100; const int INF = 2 * 1e9; struct mapa{ int val = INF; }; int n; int k; vector<pp> v[MAXN]; int p[MAXN] = { 0 }; int vel[MAXN] = { 0 }; map<int, mapa> m; vector<int> s; int sol = INF; int cnt = 0; int dfs(int x, int depth, int sum, int val, int k){ p[x] = 1; if (val == 0) ++cnt; else if (val == 1 && sum <= k){ int zb = depth + m[k - sum].val - 1; sol = min(sol, zb); } else if (val == 2 && sum <= k){ s.insert(sum); m[sum].val = min(m[sum].val, depth); } for (int i = 0; i < v[x].size(); ++i){ int y = v[x][i].first; if (!p[y]){ int rt = dfs(y, depth + 1, sum + v[x][i].second, val, k); if (val == 0) vel[x] += rt; } } if (val == 0) ++vel[x]; p[x] = 0; if (val == 0) return vel[x]; return 0; } int centr(int x){ pp maks = {-1, -1}; m[0].val = 1; for (int i = 0; i < v[x].size(); ++i){ int y = v[x][i].first; if (!p[y] && vel[y] > maks.second) maks = {y, vel[y]}; } if (maks.second <= cnt / 2) return x; return maks.first; } void solve(int x, int K){ s.clear(); for (int i = 0; i < v[x].size(); ++i){ int y = v[x][i].first; if (!p[y]){ dfs(y, 2, v[x][i].second, 1, K); dfs(y, 2, v[x][i].second, 2, K); } } while (!s.empty()){ m[s.back()].val = INF; s.pop_back(); } return; } void decompose(int x, int K){ cnt = 0; dfs(x, 1, 0, 0, K); int root = centr(x); p[root] = 1; solve(root, K); for (int i = 0; i < v[root].size(); ++i){ int y = v[root][i].first; if (!p[y]) decompose(y, K); } } int best_path(int N, int K, int H[MAXN][2], int L[MAXN]){ ios_base::sync_with_stdio(false); cin.tie(NULL); for (int i = 0; i < N - 1; ++i){ v[H[i][0]].push_back({H[i][1], L[i]}); v[H[i][1]].push_back({H[i][0], L[i]}); } decompose(0, K); if (sol == INF) return -1; else return (sol - 1); return 0; }

Compilation message (stderr)

race.cpp: In function 'int dfs(int, int, int, int, int)':
race.cpp:32:21: error: no matching function for call to 'std::vector<int>::insert(int&)'
   32 |         s.insert(sum);
      |                     ^
In file included from /usr/include/c++/10/vector:72,
                 from /usr/include/c++/10/functional:62,
                 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 race.cpp:1:
/usr/include/c++/10/bits/vector.tcc:130:5: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = std::vector<int>::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<int>::const_iterator; std::vector<_Tp, _Alloc>::value_type = int]'
  130 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:130:5: note:   candidate expects 2 arguments, 1 provided
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 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 race.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1293:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = std::vector<int>::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<int>::const_iterator; std::vector<_Tp, _Alloc>::value_type = int]'
 1293 |       insert(const_iterator __position, value_type&& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:1293:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/10/bits/stl_vector.h:1310:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = std::vector<int>::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<int>::const_iterator]'
 1310 |       insert(const_iterator __position, initializer_list<value_type> __l)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:1310:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/10/bits/stl_vector.h:1335:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = std::vector<int>::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<int>::const_iterator; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = int]'
 1335 |       insert(const_iterator __position, size_type __n, const value_type& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:1335:7: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/10/bits/stl_vector.h:1379:2: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, _InputIterator, _InputIterator) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _Tp = int; _Alloc = std::allocator<int>]'
 1379 |  insert(const_iterator __position, _InputIterator __first,
      |  ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:1379:2: note:   template argument deduction/substitution failed:
race.cpp:32:21: note:   candidate expects 3 arguments, 1 provided
   32 |         s.insert(sum);
      |                     ^
race.cpp:35:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for (int i = 0; i < v[x].size(); ++i){
      |                     ~~^~~~~~~~~~~~~
race.cpp: In function 'int centr(int)':
race.cpp:53:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |     for (int i = 0; i < v[x].size(); ++i){
      |                     ~~^~~~~~~~~~~~~
race.cpp: In function 'void solve(int, int)':
race.cpp:65:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |     for (int i = 0; i < v[x].size(); ++i){
      |                     ~~^~~~~~~~~~~~~
race.cpp: In function 'void decompose(int, int)':
race.cpp:81:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   81 |     for (int i = 0; i < v[root].size(); ++i){
      |                     ~~^~~~~~~~~~~~~~~~