Submission #445552

#TimeUsernameProblemLanguageResultExecution timeMemory
445552ACE_Zoo (COCI19_zoo)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #define f first #define s second using namespace std; const int N = 1005; int t, fix[N][N], n, m; char a[N][N]; vector<pair<int, int> > next, cur; bool ok(int i, int j) { if (min(i, j) < 1 || i > n || j > m) return 0; return 1; } void dfs(int i, int j, char c) { if (!ok(i, j) || a[i][j] != c || fix[i][j]) return; fix[i][j] = 1; next.push_back({ i,j }); dfs(i + 1, j, c); dfs(i - 1, j, c); dfs(i, j - 1, c); dfs(i, j + 1, c); } main() { cin >> n >> m; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cin >> a[i][j]; } } dfs(1, 1, a[1][1]); cur = next; next.clear(); char c = a[1][1]; int ans = 0; while (cur.size()) { ans++; c = 'T' + 'B' - c; for (int k = 0; k < cur.size(); k++) { int i = cur[k].f, j = cur[k].s; dfs(i + 1, j, c); dfs(i - 1, j, c); dfs(i, j - 1, c); dfs(i, j + 1, c); } cur = next; next.clear(); } cout << ans; }

Compilation message (stderr)

zoo.cpp: In function 'void dfs(int, int, char)':
zoo.cpp:16:2: error: reference to 'next' is ambiguous
   16 |  next.push_back({ i,j });
      |  ^~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from zoo.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:213:5: note: candidates are: 'template<class _InputIterator> _InputIterator std::next(_InputIterator, typename std::iterator_traits<_Iter>::difference_type)'
  213 |     next(_InputIterator __x, typename
      |     ^~~~
zoo.cpp:8:25: note:                 'std::vector<std::pair<int, int> > next'
    8 | vector<pair<int, int> > next, cur;
      |                         ^~~~
zoo.cpp: At global scope:
zoo.cpp:22:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   22 | main() {
      | ^~~~
zoo.cpp: In function 'int main()':
zoo.cpp:30:8: error: reference to 'next' is ambiguous
   30 |  cur = next;
      |        ^~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from zoo.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:213:5: note: candidates are: 'template<class _InputIterator> _InputIterator std::next(_InputIterator, typename std::iterator_traits<_Iter>::difference_type)'
  213 |     next(_InputIterator __x, typename
      |     ^~~~
zoo.cpp:8:25: note:                 'std::vector<std::pair<int, int> > next'
    8 | vector<pair<int, int> > next, cur;
      |                         ^~~~
zoo.cpp:31:2: error: reference to 'next' is ambiguous
   31 |  next.clear();
      |  ^~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from zoo.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:213:5: note: candidates are: 'template<class _InputIterator> _InputIterator std::next(_InputIterator, typename std::iterator_traits<_Iter>::difference_type)'
  213 |     next(_InputIterator __x, typename
      |     ^~~~
zoo.cpp:8:25: note:                 'std::vector<std::pair<int, int> > next'
    8 | vector<pair<int, int> > next, cur;
      |                         ^~~~
zoo.cpp:37:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |   for (int k = 0; k < cur.size(); k++) {
      |                   ~~^~~~~~~~~~~~
zoo.cpp:44:9: error: reference to 'next' is ambiguous
   44 |   cur = next;
      |         ^~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from zoo.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:213:5: note: candidates are: 'template<class _InputIterator> _InputIterator std::next(_InputIterator, typename std::iterator_traits<_Iter>::difference_type)'
  213 |     next(_InputIterator __x, typename
      |     ^~~~
zoo.cpp:8:25: note:                 'std::vector<std::pair<int, int> > next'
    8 | vector<pair<int, int> > next, cur;
      |                         ^~~~
zoo.cpp:45:3: error: reference to 'next' is ambiguous
   45 |   next.clear();
      |   ^~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from zoo.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:213:5: note: candidates are: 'template<class _InputIterator> _InputIterator std::next(_InputIterator, typename std::iterator_traits<_Iter>::difference_type)'
  213 |     next(_InputIterator __x, typename
      |     ^~~~
zoo.cpp:8:25: note:                 'std::vector<std::pair<int, int> > next'
    8 | vector<pair<int, int> > next, cur;
      |                         ^~~~