# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1187891 | versesrev | Tracks in the Snow (BOI13_tracks) | C++20 | Compilation error | 0 ms | 0 KiB |
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <array>
int main() {
int h, w;
std::cin >> h >> w;
std::vector<std::string> grid(h);
for (auto& s : grid) std::cin >> s;
int ans = 0;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
std::priority_queue<std::array<int, 3>> heap;
std::vector<std::vector<bool>> vis(h, std::vector<bool>(w));
heap.emplace(0, 0, 0), vis[0][0] = true;
while (not heap.empty()) {
auto [d, r, c] = heap.top();
heap.pop();
for (int k = 0; k < 4; ++k) {
int nr = r + dr[k];
int nc = c + dc[k];
if (nr < 0 or h <= nr
or nc < 0 or w <= nc
or vis[nr][nc]
or '.' == grid[nr][nc]) continue;
int nd = d - (grid[nr][nc] == grid[r][c]);
heap.emplace(nd, nr, nc);
ans = std::max(ans, -d);
}
}
std::cout << (ans + 1) << "\n";
}
Compilation message (stderr)
In file included from /usr/include/c++/11/ext/alloc_traits.h:34, from /usr/include/c++/11/bits/basic_string.h:40, from /usr/include/c++/11/string:55, 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/ostream:38, from /usr/include/c++/11/iostream:39, from tracks.cpp:1: /usr/include/c++/11/bits/alloc_traits.h: In instantiation of 'static constexpr void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = std::array<int, 3>; _Args = {int, int, int}; _Tp = std::array<int, 3>; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<std::array<int, 3> >]': /usr/include/c++/11/bits/vector.tcc:115:30: required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int, int, int}; _Tp = std::array<int, 3>; _Alloc = std::allocator<std::array<int, 3> >; std::vector<_Tp, _Alloc>::reference = std::array<int, 3>&]' /usr/include/c++/11/bits/stl_queue.h:658:18: required from 'void std::priority_queue<_Tp, _Sequence, _Compare>::emplace(_Args&& ...) [with _Args = {int, int, int}; _Tp = std::array<int, 3>; _Sequence = std::vector<std::array<int, 3>, std::allocator<std::array<int, 3> > >; _Compare = std::less<std::array<int, 3> >]' tracks.cpp:18:15: required from here /usr/include/c++/11/bits/alloc_traits.h:518:28: error: no matching function for call to 'construct_at(std::array<int, 3>*&, int, int, int)' 518 | std::construct_at(__p, std::forward<_Args>(__args)...); | ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/bits/stl_iterator.h:85, from /usr/include/c++/11/bits/stl_algobase.h:67, from /usr/include/c++/11/bits/char_traits.h:39, from /usr/include/c++/11/ios:40, from /usr/include/c++/11/ostream:38, from /usr/include/c++/11/iostream:39, from tracks.cpp:1: /usr/include/c++/11/bits/stl_construct.h:94:5: note: candidate: 'template<class _Tp, class ... _Args> constexpr decltype (::new(void*(0)) _Tp) std::construct_at(_Tp*, _Args&& ...)' 94 | construct_at(_Tp* __location, _Args&&... __args) | ^~~~~~~~~~~~ /usr/include/c++/11/bits/stl_construct.h:94:5: note: template argument deduction/substitution failed: /usr/include/c++/11/bits/stl_construct.h: In substitution of 'template<class _Tp, class ... _Args> constexpr decltype (::new(void*(0)) _Tp) std::construct_at(_Tp*, _Args&& ...) [with _Tp = std::array<int, 3>; _Args = {int, int, int}]': /usr/include/c++/11/bits/alloc_traits.h:518:21: required from 'static constexpr void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = std::array<int, 3>; _Args = {int, int, int}; _Tp = std::array<int, 3>; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<std::array<int, 3> >]' /usr/include/c++/11/bits/vector.tcc:115:30: required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int, int, int}; _Tp = std::array<int, 3>; _Alloc = std::allocator<std::array<int, 3> >; std::vector<_Tp, _Alloc>::reference = std::array<int, 3>&]' /usr/include/c++/11/bits/stl_queue.h:658:18: required from 'void std::priority_queue<_Tp, _Sequence, _Compare>::emplace(_Args&& ...) [with _Args = {int, int, int}; _Tp = std::array<int, 3>; _Sequence = std::vector<std::array<int, 3>, std::allocator<std::array<int, 3> > >; _Compare = std::less<std::array<int, 3> >]' tracks.cpp:18:15: required from here /usr/include/c++/11/bits/stl_construct.h:96:17: error: array must be initialized with a brace-enclosed initializer 96 | -> decltype(::new((void*)0) _Tp(std::declval<_Args>()...)) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/ext/alloc_traits.h:34, from /usr/include/c++/11/bits/basic_string.h:40, from /usr/include/c++/11/string:55, 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/ostream:38, from /usr/include/c++/11/iostream:39, from tracks.cpp:1: /usr/include/c++/11/bits/alloc_traits.h: In instantiation of 'static constexpr void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = std::array<int, 3>; _Args = {int&, int&, int&}; _Tp = std::array<int, 3>; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<std::array<int, 3> >]': /usr/include/c++/11/bits/vector.tcc:115:30: required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int&, int&, int&}; _Tp = std::array<int, 3>; _Alloc = std::allocator<std::array<int, 3> >; std::vector<_Tp, _Alloc>::reference = std::array<int, 3>&]' /usr/include/c++/11/bits/stl_queue.h:658:18: required from 'void std::priority_queue<_Tp, _Sequence, _Compare>::emplace(_Args&& ...) [with _Args = {int&, int&, int&}; _Tp = std::array<int, 3>; _Sequence = std::vector<std::array<int, 3>, std::allocator<std::array<int, 3> > >; _Compare = std::less<std::array<int, 3> >]' tracks.cpp:30:19: required from here /usr/include/c++/11/bits/alloc_traits.h:518:28: error: no matching function for call to 'construct_at(std::array<int, 3>*&, int&, int&, int&)' 518 | std::construct_at(__p, std::forward<_Args>(__args)...); | ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/bits/stl_iterator.h:85, from /usr/include/c++/11/bits/stl_algobase.h:67, from /usr/include/c++/11/bits/char_traits.h:39, from /usr/include/c++/11/ios:40, from /usr/include/c++/11/ostream:38, from /usr/include/c++/11/iostream:39, from tracks.cpp:1: /usr/include/c++/11/bits/stl_construct.h:94:5: note: candidate: 'template<class _Tp, class ... _Args> constexpr decltype (::new(void*(0)) _Tp) std::construct_at(_Tp*, _Args&& ...)' 94 | construct_at(_Tp* __location, _Args&&... __args) | ^~~~~~~~~~~~ /usr/include/c++/11/bits/stl_construct.h:94:5: note: template argument deduction/substitution failed: /usr/include/c++/11/bits/stl_construct.h: In substitution of 'template<class _Tp, class ... _Args> constexpr decltype (::new(void*(0)) _Tp) std::construct_at(_Tp*, _Args&& ...) [with _Tp = std::array<int, 3>; _Args = {int&, int&, int&}]': /usr/include/c++/11/bits/alloc_traits.h:518:21: required from 'static constexpr void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = std::array<int, 3>; _Args = {int&, int&, int&}; _Tp = std::array<int, 3>; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<std::array<int, 3> >]' /usr/include/c++/11/bits/vector.tcc:115:30: required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int&, int&, int&}; _Tp = std::array<int, 3>; _Alloc = std::allocator<std::array<int, 3> >; std::vector<_Tp, _Alloc>::reference = std::array<int, 3>&]' /usr/include/c++/11/bits/stl_queue.h:658:18: required from 'void std::priority_queue<_Tp, _Sequence, _Compare>::emplace(_Args&& ...) [with _Args = {int&, int&, int&}; _Tp = std::array<int, 3>; _Sequence = std::vector<std::array<int, 3>, std::allocator<std::array<int, 3> > >; _Compare = std::less<std::array<int, 3> >]' tracks.cpp:30:19: required from here /usr/include/c++/11/bits/stl_construct.h:96:17: error: array must be initialized with a brace-enclosed initializer 96 | -> decltype(::new((void*)0) _Tp(std::declval<_Args>()...)) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~