Submission #466838

#TimeUsernameProblemLanguageResultExecution timeMemory
466838dutchLinear Garden (IOI08_linear_garden)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int int64_t int N, M, dp[2][3][3], result; string S; #define s(i) (S[i] == 'P') signed main(){ cin.tie(0)->sync_with_stdio(0); cin >> N >> M >> S; dp[0][0][0] = 1; for(int i=N; --i>=0; ){ int prev[2][3][3] = {}; swap(prev, dp); for(bool a : {0, 1}){ for(int x : {0, 1, 2}){ for(int y : {0, 1, 2}){ if(x < 2) (dp[!s(i) && a][x + 1][max(y - 1, 0LL)] += prev[a][x][y]) %= M; if(y < 2) (dp[!s(i) || a][max(x - 1, 0LL)][y + 1] += prev[a][x][y]) %= M; } } } } for(int x : {0, 1, 2}) for(int y : {0, 1, 2}) (result += dp[0][x][y]) %= M; cout << result; }

Compilation message (stderr)

linear_garden.cpp: In function 'int main()':
linear_garden.cpp:24:53: error: no matching function for call to 'max(int64_t, long long int)'
   24 |      if(x < 2) (dp[!s(i) && a][x + 1][max(y - 1, 0LL)] += prev[a][x][y]) %= M;
      |                                                     ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from linear_garden.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:
linear_garden.cpp:24:53: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   24 |      if(x < 2) (dp[!s(i) && a][x + 1][max(y - 1, 0LL)] += prev[a][x][y]) %= M;
      |                                                     ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from linear_garden.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:
linear_garden.cpp:24:53: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   24 |      if(x < 2) (dp[!s(i) && a][x + 1][max(y - 1, 0LL)] += prev[a][x][y]) %= M;
      |                                                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from linear_garden.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:
linear_garden.cpp:24:53: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   24 |      if(x < 2) (dp[!s(i) && a][x + 1][max(y - 1, 0LL)] += prev[a][x][y]) %= M;
      |                                                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from linear_garden.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:
linear_garden.cpp:24:53: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   24 |      if(x < 2) (dp[!s(i) && a][x + 1][max(y - 1, 0LL)] += prev[a][x][y]) %= M;
      |                                                     ^
linear_garden.cpp:25:46: error: no matching function for call to 'max(int64_t, long long int)'
   25 |      if(y < 2) (dp[!s(i) || a][max(x - 1, 0LL)][y + 1] += prev[a][x][y]) %= M;
      |                                              ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from linear_garden.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:
linear_garden.cpp:25:46: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   25 |      if(y < 2) (dp[!s(i) || a][max(x - 1, 0LL)][y + 1] += prev[a][x][y]) %= M;
      |                                              ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from linear_garden.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:
linear_garden.cpp:25:46: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   25 |      if(y < 2) (dp[!s(i) || a][max(x - 1, 0LL)][y + 1] += prev[a][x][y]) %= M;
      |                                              ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from linear_garden.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:
linear_garden.cpp:25:46: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   25 |      if(y < 2) (dp[!s(i) || a][max(x - 1, 0LL)][y + 1] += prev[a][x][y]) %= M;
      |                                              ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from linear_garden.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:
linear_garden.cpp:25:46: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   25 |      if(y < 2) (dp[!s(i) || a][max(x - 1, 0LL)][y + 1] += prev[a][x][y]) %= M;
      |                                              ^