제출 #389887

#제출 시각아이디문제언어결과실행 시간메모리
389887null_aweTracks in the Snow (BOI13_tracks)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int main() { int h, w; cin >> h >> w; vector<vector<int>> field(h, vector<int>(w, 0)), filled(h, vector<int>(w, 0)); for (int i = 0; i < h; ++i) { string line; cin >> line; for (int j = 0; j < w; ++j) field[i][j] = (line[j] == '.' ? -1 : (line[j] == 'R' ? 1 : 2)); } int r = 0; vector<vector<int>> next(); vector<int> first{0, 0}; next.push_back(first); while (!next.empty()) { queue<vector<int>> q(); for (vector<int> go : next) q.push(go); next.clear(); while (!q.empty()) { vector<int> square = q.front(); q.pop(); for (int a = -1; a < 2; a += 2) { int newX = square[0] + a, newY = square[1]; if (newX < 0 || newY < 0 || newX >= h || newY >= w) continue; if (filled[newX][newY] > 0 || field[newX][newY] < 0) continue; vector<int> add{newX, newY}; if (field[newX][newY] == field[square[0]][square[1]]) q.push(add); else next.push_back(add); } for (int a = -1; a < 2; a += 2) { int newX = square[0], newY = square[1] + a; if (newX < 0 || newY < 0 || newX >= h || newY >= w) continue; if (filled[newX][newY] > 0 || field[newX][newY] < 0) continue; vector<int> add{newX, newY}; if (field[newX][newY] == field[square[0]][square[1]]) q.push(add); else next.push_back(add); } filled[square[0]][square[1]] = 1; } r++; } cout << r; return 0; }

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

tracks.cpp: In function 'int main()':
tracks.cpp:16:8: error: request for member 'push_back' in 'next', which is of non-class type 'std::vector<std::vector<int> >()'
   16 |   next.push_back(first);
      |        ^~~~~~~~~
tracks.cpp:17:16: error: request for member 'empty' in 'next', which is of non-class type 'std::vector<std::vector<int> >()'
   17 |   while (!next.empty()) {
      |                ^~~~~
tracks.cpp:19:27: error: no matching function for call to 'begin(std::vector<std::vector<int> > (&)())'
   19 |     for (vector<int> go : next) q.push(go);
      |                           ^~~~
In file included from /usr/include/c++/9/bits/range_access.h:36,
                 from /usr/include/c++/9/string:54,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from tracks.cpp:1:
/usr/include/c++/9/initializer_list:89:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::begin(std::initializer_list<_Tp>)'
   89 |     begin(initializer_list<_Tp> __ils) noexcept
      |     ^~~~~
/usr/include/c++/9/initializer_list:89:5: note:   template argument deduction/substitution failed:
tracks.cpp:19:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'std::vector<std::vector<int> > (*)()'
   19 |     for (vector<int> go : next) q.push(go);
      |                           ^~~~
In file included from /usr/include/c++/9/string:54,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from tracks.cpp:1:
/usr/include/c++/9/bits/range_access.h:48:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&)'
   48 |     begin(_Container& __cont) -> decltype(__cont.begin())
      |     ^~~~~
/usr/include/c++/9/bits/range_access.h:48:5: note:   template argument deduction/substitution failed:
/usr/include/c++/9/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&) [with _Container = std::vector<std::vector<int> >()]':
tracks.cpp:19:27:   required from here
/usr/include/c++/9/bits/range_access.h:48:50: error: request for member 'begin' in '__cont', which is of non-class type 'std::vector<std::vector<int> >()'
   48 |     begin(_Container& __cont) -> decltype(__cont.begin())
      |                                           ~~~~~~~^~~~~
/usr/include/c++/9/bits/range_access.h:58:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(const _Container&)'
   58 |     begin(const _Container& __cont) -> decltype(__cont.begin())
      |     ^~~~~
/usr/include/c++/9/bits/range_access.h:58:5: note:   template argument deduction/substitution failed:
/usr/include/c++/9/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(const _Container&) [with _Container = std::vector<std::vector<int> >()]':
tracks.cpp:19:27:   required from here
/usr/include/c++/9/bits/range_access.h:58:56: error: request for member 'begin' in '__cont', which is of non-class type 'std::vector<std::vector<int> >()'
   58 |     begin(const _Container& __cont) -> decltype(__cont.begin())
      |                                                 ~~~~~~~^~~~~
/usr/include/c++/9/bits/range_access.h:87:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::begin(_Tp (&)[_Nm])'
   87 |     begin(_Tp (&__arr)[_Nm])
      |     ^~~~~
/usr/include/c++/9/bits/range_access.h:87:5: note:   template argument deduction/substitution failed:
tracks.cpp:19:27: note:   mismatched types '_Tp [_Nm]' and 'std::vector<std::vector<int> >()'
   19 |     for (vector<int> go : next) q.push(go);
      |                           ^~~~
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:95,
                 from tracks.cpp:1:
/usr/include/c++/9/valarray:1214:5: note: candidate: 'template<class _Tp> _Tp* std::begin(std::valarray<_Tp>&)'
 1214 |     begin(valarray<_Tp>& __va)
      |     ^~~~~
/usr/include/c++/9/valarray:1214:5: note:   template argument deduction/substitution failed:
tracks.cpp:19:27: note:   mismatched types 'std::valarray<_Tp>' and 'std::vector<std::vector<int> >()'
   19 |     for (vector<int> go : next) q.push(go);
      |                           ^~~~
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:95,
                 from tracks.cpp:1:
/usr/include/c++/9/valarray:1224:5: note: candidate: 'template<class _Tp> const _Tp* std::begin(const std::valarray<_Tp>&)'
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
/usr/include/c++/9/valarray:1224:5: note:   template argument deduction/substitution failed:
tracks.cpp:19:27: note:   mismatched types 'const std::valarray<_Tp>' and 'std::vector<std::vector<int> >()'
   19 |     for (vector<int> go : next) q.push(go);
      |                           ^~~~
tracks.cpp:19:27: error: no matching function for call to 'end(std::vector<std::vector<int> > (&)())'
In file included from /usr/include/c++/9/bits/range_access.h:36,
                 from /usr/include/c++/9/string:54,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from tracks.cpp:1:
/usr/include/c++/9/initializer_list:99:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)'
   99 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
/usr/include/c++/9/initializer_list:99:5: note:   template argument deduction/substitution failed:
tracks.cpp:19:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'std::vector<std::vector<int> > (*)()'
   19 |     for (vector<int> go : next) q.push(go);
      |                           ^~~~
In file included from /usr/include/c++/9/string:54,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from tracks.cpp:1:
/usr/include/c++/9/bits/range_access.h:68:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
   68 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/9/bits/range_access.h:68:5: note:   template argument deduction/substitution failed:
/usr/include/c++/9/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&) [with _Container = std::vector<std::vector<int> >()]':
tracks.cpp:19:27:   required from here
/usr/include/c++/9/bits/range_access.h:68:48: error: request for member 'end' in '__cont', which is of non-class type 'std::vector<std::vector<int> >()'
   68 |     end(_Container& __cont) -> decltype(__cont.end())
      |                                         ~~~~~~~^~~
/usr/include/c++/9/bits/range_access.h:78:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
   78 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/9/bits/range_access.h:78:5: note:   template argument deduction/substitution failed:
/usr/include/c++/9/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&) [with _Container = std::vector<std::vector<int> >()]':
tracks.cpp:19:27:   required from here
/usr/include/c++/9/bits/range_access.h:78:54: error: request for member 'end' in '__cont', which is of non-class type 'std::vector<std::vector<int> >()'
   78 |     end(const _Container& __cont) -> decltype(__cont.end())
      |                                               ~~~~~~~^~~
/usr/include/c++/9/bits/range_access.h:97:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
   97 |     end(_Tp (&__arr)[_Nm])
      |     ^~~
/usr/include/c++/9/bits/range_access.h:97:5: note:   template argument deduction/substitution failed:
tracks.cpp:19:27: note:   mismatched types '_Tp [_Nm]' and 'std::vector<std::vector<int> >()'
   19 |     for (vector<int> go : next) q.push(go);
      |                           ^~~~
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:95,
                 from tracks.cpp:1:
/usr/include/c++/9/valarray:1234:5: note: candidate: 'template<class _Tp> _Tp* std::end(std::valarray<_Tp>&)'
 1234 |     end(valarray<_Tp>& __va)
      |     ^~~
/usr/include/c++/9/valarray:1234:5: note:   template argument deduction/substitution failed:
tracks.cpp:19:27: note:   mismatched types 'std::valarray<_Tp>' and 'std::vector<std::vector<int> >()'
   19 |     for (vector<int> go : next) q.push(go);
      |                           ^~~~
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:95,
                 from tracks.cpp:1:
/usr/include/c++/9/valarray:1244:5: note: candidate: 'template<class _Tp> const _Tp* std::end(const std::valarray<_Tp>&)'
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
/usr/include/c++/9/valarray:1244:5: note:   template argument deduction/substitution failed:
tracks.cpp:19:27: note:   mismatched types 'const std::valarray<_Tp>' and 'std::vector<std::vector<int> >()'
   19 |     for (vector<int> go : next) q.push(go);
      |                           ^~~~
tracks.cpp:19:35: error: request for member 'push' in 'q', which is of non-class type 'std::queue<std::vector<int> >()'
   19 |     for (vector<int> go : next) q.push(go);
      |                                   ^~~~
tracks.cpp:20:10: error: request for member 'clear' in 'next', which is of non-class type 'std::vector<std::vector<int> >()'
   20 |     next.clear();
      |          ^~~~~
tracks.cpp:21:15: error: request for member 'empty' in 'q', which is of non-class type 'std::queue<std::vector<int> >()'
   21 |     while (!q.empty()) {
      |               ^~~~~
tracks.cpp:22:30: error: request for member 'front' in 'q', which is of non-class type 'std::queue<std::vector<int> >()'
   22 |       vector<int> square = q.front();
      |                              ^~~~~
tracks.cpp:23:9: error: request for member 'pop' in 'q', which is of non-class type 'std::queue<std::vector<int> >()'
   23 |       q.pop();
      |         ^~~
tracks.cpp:29:65: error: request for member 'push' in 'q', which is of non-class type 'std::queue<std::vector<int> >()'
   29 |         if (field[newX][newY] == field[square[0]][square[1]]) q.push(add);
      |                                                                 ^~~~
tracks.cpp:30:19: error: request for member 'push_back' in 'next', which is of non-class type 'std::vector<std::vector<int> >()'
   30 |         else next.push_back(add);
      |                   ^~~~~~~~~
tracks.cpp:37:65: error: request for member 'push' in 'q', which is of non-class type 'std::queue<std::vector<int> >()'
   37 |         if (field[newX][newY] == field[square[0]][square[1]]) q.push(add);
      |                                                                 ^~~~
tracks.cpp:38:19: error: request for member 'push_back' in 'next', which is of non-class type 'std::vector<std::vector<int> >()'
   38 |         else next.push_back(add);
      |                   ^~~~~~~~~