답안 #962613

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
962613 2024-04-14T02:52:28 Z novus677 Tracks in the Snow (BOI13_tracks) C++14
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

int H, W;
char grid[4000][4000];
bool visited[4000][4000];
char cur;

int main() {
    cin >> H >> W;

    for (int i = 0; i < H; ++i) {
        string row;
        cin >> row;
        for (int j = 0; j < W; ++j) {
            grid[i][j] = row[j];
        }
    }
    cur = grid[0][0];

    int answer = 1;
    priority_queue<tuple<int, int, int>> queue;
    queue.push({-1, 0, 0});
    visited[0][0] = true;
    while (!queue.empty()) {
        auto [marker, i, j] = queue.top();
        queue.pop();
        answer = max(answer, -marker);

        if (i > 0 && !visited[i - 1][j]) {
            if (grid[i - 1][j] == grid[i][j]) {
                visited[i - 1][j] = true;
                queue.push({marker, i - 1, j});
            } else if (grid[i - 1][j] != '.') {
                visited[i - 1][j] = true;
                queue.push({marker - 1, i - 1, j});
            }
        }
        if (i < H - 1 && !visited[i + 1][j]) {
            if (grid[i + 1][j] == grid[i][j]) {
                visited[i + 1][j] = true;
                queue.push({marker, i + 1, j});
            } else if (grid[i + 1][j] != '.') {
                visited[i + 1][j] = true;
                queue.push({marker - 1, i + 1, j});
            }
        }
        if (j > 0 && !visited[i][j - 1]) {
            if (grid[i][j - 1] == grid[i][j]) {
                visited[i][j - 1] = true;
                queue.push({marker, i, j - 1});
            } else if (grid[i][j - 1] != '.') {
                visited[i][j - 1] = true;
                queue.push({marker - 1, i, j - 1});
            }
        }
        if (j < W - 1 && !visited[i][j + 1]) {
            if (grid[i][j + 1] == grid[i][j]) {
                visited[i][j + 1] = true;
                queue.push({marker, i, j + 1});
            } else if (grid[i][j + 1] != '.') {
                visited[i][j + 1] = true;
                queue.push({marker - 1, i, j + 1});
            }
        }
    }

    cout << answer << '\n';
}

Compilation message

tracks.cpp: In function 'int main()':
tracks.cpp:26:26: error: no matching function for call to 'std::priority_queue<std::tuple<int, int, int> >::push(<brace-enclosed initializer list>)'
   26 |     queue.push({-1, 0, 0});
      |                          ^
In file included from /usr/include/c++/10/queue:64,
                 from tracks.cpp:2:
/usr/include/c++/10/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; _Compare = std::less<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:640:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::tuple<int, int, int>&'}
  640 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:648:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; _Compare = std::less<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:648:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::tuple<int, int, int> >::value_type&&' {aka 'std::tuple<int, int, int>&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
tracks.cpp:29:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   29 |         auto [marker, i, j] = queue.top();
      |              ^
tracks.cpp:29:14: error: 'std::tuple<int, int, int> <structured bindings>' has incomplete type
   29 |         auto [marker, i, j] = queue.top();
      |              ^~~~~~~~~~~~~~
tracks.cpp:36:46: error: no matching function for call to 'std::priority_queue<std::tuple<int, int, int> >::push(<brace-enclosed initializer list>)'
   36 |                 queue.push({marker, i - 1, j});
      |                                              ^
In file included from /usr/include/c++/10/queue:64,
                 from tracks.cpp:2:
/usr/include/c++/10/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; _Compare = std::less<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:640:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::tuple<int, int, int>&'}
  640 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:648:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; _Compare = std::less<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:648:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::tuple<int, int, int> >::value_type&&' {aka 'std::tuple<int, int, int>&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
tracks.cpp:39:50: error: no matching function for call to 'std::priority_queue<std::tuple<int, int, int> >::push(<brace-enclosed initializer list>)'
   39 |                 queue.push({marker - 1, i - 1, j});
      |                                                  ^
In file included from /usr/include/c++/10/queue:64,
                 from tracks.cpp:2:
/usr/include/c++/10/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; _Compare = std::less<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:640:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::tuple<int, int, int>&'}
  640 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:648:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; _Compare = std::less<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:648:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::tuple<int, int, int> >::value_type&&' {aka 'std::tuple<int, int, int>&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
tracks.cpp:45:46: error: no matching function for call to 'std::priority_queue<std::tuple<int, int, int> >::push(<brace-enclosed initializer list>)'
   45 |                 queue.push({marker, i + 1, j});
      |                                              ^
In file included from /usr/include/c++/10/queue:64,
                 from tracks.cpp:2:
/usr/include/c++/10/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; _Compare = std::less<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:640:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::tuple<int, int, int>&'}
  640 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:648:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; _Compare = std::less<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:648:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::tuple<int, int, int> >::value_type&&' {aka 'std::tuple<int, int, int>&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
tracks.cpp:48:50: error: no matching function for call to 'std::priority_queue<std::tuple<int, int, int> >::push(<brace-enclosed initializer list>)'
   48 |                 queue.push({marker - 1, i + 1, j});
      |                                                  ^
In file included from /usr/include/c++/10/queue:64,
                 from tracks.cpp:2:
/usr/include/c++/10/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; _Compare = std::less<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:640:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::tuple<int, int, int>&'}
  640 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:648:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; _Compare = std::less<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:648:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::tuple<int, int, int> >::value_type&&' {aka 'std::tuple<int, int, int>&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
tracks.cpp:54:46: error: no matching function for call to 'std::priority_queue<std::tuple<int, int, int> >::push(<brace-enclosed initializer list>)'
   54 |                 queue.push({marker, i, j - 1});
      |                                              ^
In file included from /usr/include/c++/10/queue:64,
                 from tracks.cpp:2:
/usr/include/c++/10/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; _Compare = std::less<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:640:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::tuple<int, int, int>&'}
  640 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:648:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; _Compare = std::less<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:648:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::tuple<int, int, int> >::value_type&&' {aka 'std::tuple<int, int, int>&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
tracks.cpp:57:50: error: no matching function for call to 'std::priority_queue<std::tuple<int, int, int> >::push(<brace-enclosed initializer list>)'
   57 |                 queue.push({marker - 1, i, j - 1});
      |                                                  ^
In file included from /usr/include/c++/10/queue:64,
                 from tracks.cpp:2:
/usr/include/c++/10/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; _Compare = std::less<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:640:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::tuple<int, int, int>&'}
  640 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:648:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; _Compare = std::less<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:648:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::tuple<int, int, int> >::value_type&&' {aka 'std::tuple<int, int, int>&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
tracks.cpp:63:46: error: no matching function for call to 'std::priority_queue<std::tuple<int, int, int> >::push(<brace-enclosed initializer list>)'
   63 |                 queue.push({marker, i, j + 1});
      |                                              ^
In file included from /usr/include/c++/10/queue:64,
                 from tracks.cpp:2:
/usr/include/c++/10/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; _Compare = std::less<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:640:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::tuple<int, int, int>&'}
  640 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:648:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; _Compare = std::less<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:648:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::tuple<int, int, int> >::value_type&&' {aka 'std::tuple<int, int, int>&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
tracks.cpp:66:50: error: no matching function for call to 'std::priority_queue<std::tuple<int, int, int> >::push(<brace-enclosed initializer list>)'
   66 |                 queue.push({marker - 1, i, j + 1});
      |                                                  ^
In file included from /usr/include/c++/10/queue:64,
                 from tracks.cpp:2:
/usr/include/c++/10/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; _Compare = std::less<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:640:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::tuple<int, int, int>&'}
  640 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:648:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; _Compare = std::less<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:648:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::tuple<int, int, int> >::value_type&&' {aka 'std::tuple<int, int, int>&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from tracks.cpp:2:
/usr/include/c++/10/bits/stl_vector.h: In instantiation of 'std::_Vector_base<_Tp, _Alloc>::~_Vector_base() [with _Tp = std::tuple<int, int, int>; _Alloc = std::allocator<std::tuple<int, int, int> >]':
/usr/include/c++/10/bits/stl_vector.h:487:7:   required from 'std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue() [with _Seq = std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; _Requires = void; _Tp = std::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; _Compare = std::less<std::tuple<int, int, int> >]'
tracks.cpp:25:42:   required from here
/usr/include/c++/10/bits/stl_vector.h:336:35: error: invalid use of incomplete type 'class std::tuple<int, int, int>'
  336 |         _M_impl._M_end_of_storage - _M_impl._M_start);
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/bits/move.h:57,
                 from /usr/include/c++/10/bits/nested_exception.h:40,
                 from /usr/include/c++/10/exception:148,
                 from /usr/include/c++/10/ios:39,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from tracks.cpp:1:
/usr/include/c++/10/type_traits:2631:11: note: declaration of 'class std::tuple<int, int, int>'
 2631 |     class tuple;
      |           ^~~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/bits/cha