Submission #769505

#TimeUsernameProblemLanguageResultExecution timeMemory
769505EllinorTracks in the Snow (BOI13_tracks)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i = (a); i < (b); i++) typedef long long ll; int H, W; vector<string> grid; vector<vector<bool>> visited; // bitset ? vector<vector<ll>> dp; priority_queue<vector<ll>> q; void dfs(int hat, int wat, ll num) { if (visited[hat][wat]>0) return; if (grid[hat][wat] == '.') return; visited[hat][wat] = num; char ch = grid[hat][wat]; if (hat + 1 < H) { if (grid[hat + 1][wat] == ch) q.push({-num, hat + 1, wat}); else q.push({-(num + 1), hat + 1, wat}); } if (wat + 1 < W) { if (grid[hat][wat + 1] == ch) q.push({-num, hat, wat + 1}); else q.push({-(num + 1), hat, wat + 1}); } if (hat - 1 >= 0) { if (grid[hat - 1][wat] == ch) q.push({-num, hat - 1, wat}); else q.push({-(num + 1), hat - 1, wat}); } if (wat - 1 >= 0) { if (grid[hat][wat - 1] == ch) q.push({-num, hat, wat - 1}); else q.push({-(num + 1), hat, wat - 1}); } } int32_t main() { cin>>H>>W; grid.assign(H, ""); rep(i,0,H){ cin>>grid[i]; } visited.assign(H, vector<bool>(W, false)); dp.assign(H, vector<ll>(W, 0)); q.push({-1,0,0}); while(!q.empty()) { vector<ll> x = q.top(); q.pop(); dfs(x[1], x[2], -(x[0])); } ll ans = 1; rep(i,0,H){ rep(j,0,W){ ans = max(ans, visited[i][j]); } } cout << ans; }

Compilation message (stderr)

tracks.cpp: In function 'int32_t main()':
tracks.cpp:61:41: error: no matching function for call to 'max(ll&, std::vector<bool>::reference)'
   61 |             ans = max(ans, visited[i][j]);
      |                                         ^
In file included 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 tracks.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
tracks.cpp:61:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::vector<bool>::reference')
   61 |             ans = max(ans, visited[i][j]);
      |                                         ^
In file included 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 tracks.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
tracks.cpp:61:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::vector<bool>::reference')
   61 |             ans = max(ans, visited[i][j]);
      |                                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from tracks.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
tracks.cpp:61:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   61 |             ans = max(ans, visited[i][j]);
      |                                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from tracks.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
tracks.cpp:61:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   61 |             ans = max(ans, visited[i][j]);
      |                                         ^