Submission #1256276

#TimeUsernameProblemLanguageResultExecution timeMemory
1256276ericl23302Tracks in the Snow (BOI13_tracks)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int h, w; cin >> h >> w; vector<vector<char>> grid(h, vector<int>(w, 0)); vector<vector<pair<int, int>>> adjacency(h * w); for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { cin >> grid[i][j]; if (i && grid[i - 1][j] != '.') { if (grid[i - 1][j] == grid[i][j]) { adjacency[i * w - w + j].emplace_back(i * w + j, 0); adjacency[i * w + j].emplace_back(i * w - w + j, 0); } else { adjacency[i * w - w + j].emplace_back(i * w + j, 1); adjacency[i * w + j].emplace_back(i * w - w + j, 1); } } if (j && grid[i][j - 1] != '.') { if (grid[i][j - 1] == grid[i][j]) { adjacency[i * w - 1 + j].emplace_back(i * w + j, 0); adjacency[i * w + j].emplace_back(i * w - 1 + j, 0); } else { adjacency[i * w - 1 + j].emplace_back(i * w + j, 1); adjacency[i * w + j].emplace_back(i * w - 1 + j, 1); } } } } vector<short> distances(h * w, -1); distances[0] = 1; deque<int> q; q.push_front(0); while (!q.empty()) { int cur = q.front(); q.pop_front(); for (auto &i : adjacency[cur]) { if (distances[i.first] != -1) continue; distances[i.first] = distances[cur] + i.second; if (i.second) q.push_back(i.first); else q.push_front(i.first); } } int res = 0; for (auto &i : distances) res = max(res, i); cout << res << '\n'; return 0; }

Compilation message (stderr)

tracks.cpp: In function 'int main()':
tracks.cpp:11:51: error: no matching function for call to 'std::vector<std::vector<char> >::vector(int&, std::vector<int>)'
   11 |     vector<vector<char>> grid(h, vector<int>(w, 0));
      |                                                   ^
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from tracks.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:653:9: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _Tp = std::vector<char>; _Alloc = std::allocator<std::vector<char> >]'
  653 |         vector(_InputIterator __first, _InputIterator __last,
      |         ^~~~~~
/usr/include/c++/11/bits/stl_vector.h:653:9: note:   template argument deduction/substitution failed:
tracks.cpp:11:51: note:   deduced conflicting types for parameter '_InputIterator' ('int' and 'std::vector<int>')
   11 |     vector<vector<char>> grid(h, vector<int>(w, 0));
      |                                                   ^
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from tracks.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:625:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = std::vector<char>; _Alloc = std::allocator<std::vector<char> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::vector<char> >]'
  625 |       vector(initializer_list<value_type> __l,
      |       ^~~~~~
/usr/include/c++/11/bits/stl_vector.h:625:43: note:   no known conversion for argument 1 from 'int' to 'std::initializer_list<std::vector<char> >'
  625 |       vector(initializer_list<value_type> __l,
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_vector.h:607:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&) [with _Tp = std::vector<char>; _Alloc = std::allocator<std::vector<char> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::vector<char> >]'
  607 |       vector(vector&& __rv, const allocator_type& __m)
      |       ^~~~~~
/usr/include/c++/11/bits/stl_vector.h:607:23: note:   no known conversion for argument 1 from 'int' to 'std::vector<std::vector<char> >&&'
  607 |       vector(vector&& __rv, const allocator_type& __m)
      |              ~~~~~~~~~^~~~
/usr/include/c++/11/bits/stl_vector.h:589:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::false_type) [with _Tp = std::vector<char>; _Alloc = std::allocator<std::vector<char> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::vector<char> >; std::false_type = std::integral_constant<bool, false>]'
  589 |       vector(vector&& __rv, const allocator_type& __m, false_type)
      |       ^~~~~~
/usr/include/c++/11/bits/stl_vector.h:589:7: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/11/bits/stl_vector.h:585:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::true_type) [with _Tp = std::vector<char>; _Alloc = std::allocator<std::vector<char> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::vector<char> >; std::true_type = std::integral_constant<bool, true>]'
  585 |       vector(vector&& __rv, const allocator_type& __m, true_type) noexcept
      |       ^~~~~~
/usr/include/c++/11/bits/stl_vector.h:585:7: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/11/bits/stl_vector.h:575:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&, const allocator_type&) [with _Tp = std::vector<char>; _Alloc = std::allocator<std::vector<char> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::vector<char> >]'
  575 |       vector(const vector& __x, const allocator_type& __a)
      |       ^~~~~~
/usr/include/c++/11/bits/stl_vector.h:575:28: note:   no known conversion for argument 1 from 'int' to 'const std::vector<std::vector<char> >&'
  575 |       vector(const vector& __x, const allocator_type& __a)
      |              ~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_vector.h:572:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&) [with _Tp = std::vector<char>; _Alloc = std::allocator<std::vector<char> >]'
  572 |       vector(vector&&) noexcept = default;
      |       ^~~~~~
/usr/include/c++/11/bits/stl_vector.h:572:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/11/bits/stl_vector.h:553:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = std::vector<char>; _Alloc = std::allocator<std::vector<char> >]'
  553 |       vector(const vector& __x)
      |       ^~~~~~
/usr/include/c++/11/bits/stl_vector.h:553:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/11/bits/stl_vector.h:522:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const value_type&, const allocator_type&) [with _Tp = std::vector<char>; _Alloc = std::allocator<std::vector<char> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = std::vector<char>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::vector<char> >]'
  522 |       vector(size_type __n, const value_type& __value,
      |       ^~~~~~
/usr/include/c++/11/bits/stl_vector.h:522:47: note:   no known conversion for argument 2 from 'std::vector<int>' to 'const value_type&' {aka 'const std::vector<char>&'}
  522 |       vector(size_type __n, const value_type& __value,
      |                             ~~~~~~~~~~~~~~~~~~^~~~~~~
/usr/include/c++/11/bits/stl_vector.h:510:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const allocator_type&) [with _Tp = std::vector<char>; _Alloc = std::allocator<std::vector<char> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::vector<char> >]'
  510 |       vector(size_type __n, const allocator_type& __a = allocator_type())
      |       ^~~~~~
/usr/include/c++/11/bits/stl_vector.h:510:51: note:   no known conversion for argument 2 from 'std::vector<int>' to 'const allocator_type&' {aka 'const std::allocator<std::vector<char> >&'}
  510 |       vector(size_type __n, const allocator_type& __a = allocator_type())
      |                             ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:497:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = std::vector<char>; _Alloc = std::allocator<std::vector<char> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::vector<char> >]'
  497 |       vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT
      |       ^~~~~~
/usr/include/c++/11/bits/stl_vector.h:497:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/11/bits/stl_vector.h:487:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector() [with _Tp = std::vector<char>; _Alloc = std::allocator<std::vector<char> >]'
  487 |       vector() = default;
      |       ^~~~~~
/usr/include/c++/11/bits/stl_vector.h:487:7: note:   candidate expects 0 arguments, 2 provided
tracks.cpp:59:40: error: no matching function for call to 'max(int&, short int&)'
   59 |     for (auto &i : distances) res = max(res, i);
      |                                     ~~~^~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from tracks.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
tracks.cpp:59:40: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'short int')
   59 |     for (auto &i : distances) res = max(res, i);
      |                                     ~~~^~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from tracks.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
tracks.cpp:59:40: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'short int')
   59 |     for (auto &i : distances) res = max(res, i);
      |                                     ~~~^~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from tracks.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
tracks.cpp:59:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   59 |     for (auto &i : distances) res = max(res, i);
      |                                     ~~~^~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from tracks.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
tracks.cpp:59:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   59 |     for (auto &i : distances) res = max(res, i);
      |                                     ~~~^~~~~~~~