제출 #1187901

#제출 시각아이디문제언어결과실행 시간메모리
1187901versesrevTracks in the Snow (BOI13_tracks)C++20
컴파일 에러
0 ms0 KiB
#include <iostream> #include <vector> #include <string> #include <deque> #include <tuple> 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::deque<std::tuple<int, int, int>> que[2]; std::vector<std::vector<bool>> vis(h, std::vector<bool>(w)); int cur = 0; que[cur].emplace(0, 0, 0), vis[0][0] = true; while (not que[cur].empty() or not que[cur^1].empty()) { if (que[cur].empty()) cur ^= 1; auto [d, r, c] = que[cur].top(); que[cur].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]); que[cur^1].emplace(nd, nr, nc); vis[nr][nc] = true; ans = std::max(ans, -d); } } std::cout << (ans + 1) << "\n"; }

컴파일 시 표준 에러 (stderr) 메시지

tracks.cpp: In function 'int main()':
tracks.cpp:19:19: error: no matching function for call to 'std::deque<std::tuple<int, int, int> >::emplace(int, int, int)'
   19 |   que[cur].emplace(0, 0, 0), vis[0][0] = true;
      |   ~~~~~~~~~~~~~~~~^~~~~~~~~
In file included from /usr/include/c++/11/deque:67,
                 from tracks.cpp:4:
/usr/include/c++/11/bits/stl_deque.h:1581:9: note: candidate: 'template<class ... _Args> std::deque<_Tp, _Alloc>::iterator std::deque<_Tp, _Alloc>::emplace(std::deque<_Tp, _Alloc>::const_iterator, _Args&& ...) [with _Args = {_Args ...}; _Tp = std::tuple<int, int, int>; _Alloc = std::allocator<std::tuple<int, int, int> >]'
 1581 |         emplace(const_iterator __position, _Args&&... __args);
      |         ^~~~~~~
/usr/include/c++/11/bits/stl_deque.h:1581:9: note:   template argument deduction/substitution failed:
tracks.cpp:19:20: note:   cannot convert '0' (type 'int') to type 'std::deque<std::tuple<int, int, int> >::const_iterator' {aka 'std::_Deque_base<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >::const_iterator'}
   19 |   que[cur].emplace(0, 0, 0), vis[0][0] = true;
      |                    ^
tracks.cpp:22:31: error: 'class std::deque<std::tuple<int, int, int> >' has no member named 'top'
   22 |     auto [d, r, c] = que[cur].top();
      |                               ^~~
tracks.cpp:23:14: error: 'class std::deque<std::tuple<int, int, int> >' has no member named 'pop'
   23 |     que[cur].pop();
      |              ^~~
tracks.cpp:32:25: error: no matching function for call to 'std::deque<std::tuple<int, int, int> >::emplace(int&, int&, int&)'
   32 |       que[cur^1].emplace(nd, nr, nc);
      |       ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
In file included from /usr/include/c++/11/deque:67,
                 from tracks.cpp:4:
/usr/include/c++/11/bits/stl_deque.h:1581:9: note: candidate: 'template<class ... _Args> std::deque<_Tp, _Alloc>::iterator std::deque<_Tp, _Alloc>::emplace(std::deque<_Tp, _Alloc>::const_iterator, _Args&& ...) [with _Args = {_Args ...}; _Tp = std::tuple<int, int, int>; _Alloc = std::allocator<std::tuple<int, int, int> >]'
 1581 |         emplace(const_iterator __position, _Args&&... __args);
      |         ^~~~~~~
/usr/include/c++/11/bits/stl_deque.h:1581:9: note:   template argument deduction/substitution failed:
tracks.cpp:32:26: note:   cannot convert 'nd' (type 'int') to type 'std::deque<std::tuple<int, int, int> >::const_iterator' {aka 'std::_Deque_base<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >::const_iterator'}
   32 |       que[cur^1].emplace(nd, nr, nc);
      |                          ^~