Submission #389886

#TimeUsernameProblemLanguageResultExecution timeMemory
389886null_aweTracks in the Snow (BOI13_tracks)C++14
Compilation error
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)), rank(h, vector<int>(w, -1)), 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 rank = 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; } rank++; } cout << rank; return 0; }

Compilation message (stderr)

tracks.cpp: In function 'int main()':
tracks.cpp:13:7: error: conflicting declaration 'int rank'
   13 |   int rank = 0;
      |       ^~~~
tracks.cpp:7:52: note: previous declaration as 'std::vector<std::vector<int> > rank'
    7 |   vector<vector<int>> field(h, vector<int>(w, 0)), rank(h, vector<int>(w, -1)), filled(h, vector<int>(w, 0));
      |                                                    ^~~~
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> 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> 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> 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> 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> 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> 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> 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> 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);
      |                   ^~~~~~~~~
tracks.cpp:42:9: error: no 'operator++(int)' declared for postfix '++' [-fpermissive]
   42 |     rank++;
      |     ~~~~^~
tracks.cpp:44:8: error: no match for 'operator<<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'std::vector<std::vector<int> >')
   44 |   cout << rank;
      |   ~~~~ ^~ ~~~~
      |   |       |
      |   |       std::vector<std::vector<int> >
      |   std::ostream {aka std::basic_ostream<char>}
In file included from /usr/include/c++/9/istream:39,
                 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/ostream:108:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ostream_type& (*)(std::basic_ostream<_CharT, _Traits>::__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]'
  108 |       operator<<(__ostream_type& (*__pf)(__ostream_type&))
      |       ^~~~~~~~
/usr/include/c++/9/ostream:108:36: note:   no known conversion for argument 1 from 'std::vector<std::vector<int> >' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'}
  108 |       operator<<(__ostream_type& (*__pf)(__ostream_type&))
      |                  ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/9/ostream:117:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ios_type& (*)(std::basic_ostream<_CharT, _Traits>::__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>; std::basic_ostream<_CharT, _Traits>::__ios_type = std::basic_ios<char>]'
  117 |       operator<<(__ios_type& (*__pf)(__ios_type&))
      |       ^~~~~~~~
/usr/include/c++/9/ostream:117:32: note:   no known conversion for argument 1 from 'std::vector<std::vector<int> >' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'}
  117 |       operator<<(__ios_type& (*__pf)(__ios_type&))
      |                  ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/9/ostream:127:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]'
  127 |       operator<<(ios_base& (*__pf) (ios_base&))
      |       ^~~~~~~~
/usr/include/c++/9/ostream:127:30: note:   no known conversion for argument 1 from 'std::vector<std::vector<int> >' to 'std::ios_base& (*)(std::ios_base&)'
  127 |       operator<<(ios_base& (*__pf) (ios_base&))
      |                  ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/9/ostream:166:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]'
  166 |       operator<<(long __n)
      |       ^~~~~~~~
/usr/include/c++/9/ostream:166:23: note:   no known conversion for argument 1 from 'std::vector<std::vector<int> >' to 'long int'
  166 |       operator<<(long __n)
      |                  ~~~~~^~~
/usr/include/c++/9/ostream:170:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]'
  170 |       operator<<(unsigned long __n)
      |       ^~~~~~~~
/usr/include/c++/9/ostream:170:32: note:   no known conversion for argument 1 from 'std::vector<std::vector<int> >' to 'long unsigned int'
  170 |       operator<<(unsigned long __n)
      |                  ~~~~~~~~~~~~~~^~~
/usr/include/c++/9/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]'
  174 |       operator<<(bool __n)
      |       ^~~~~~~~
/usr/include/c++/9/ostream:174:23: note:   no known conversion for argument 1 from 'std::vector<std::vector<int> >' to 'bool'
  174 |       operator<<(bool __n)
      |                  ~~~~~^~~
In file included from /usr/include/c++/9/ostream:702,
                 from /usr/include/c++/9/istream:39,
                 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/ostream.tcc:91:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]'
   91 |     basic_ostream<_CharT, _Traits>::
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/9/bits/ostream.tcc:92:22: note:   no known conversion for argument 1 from 'std::vector<std::v