답안 #782519

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
782519 2023-07-14T04:08:46 Z phoebe Linear Garden (IOI08_linear_garden) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ll long long
#define pii pair<int, int>
#define F first
#define S second
#define PB push_back
#define ALL(x) x.begin(), x.end()
#define FOR(i, n) for (int i = 0; i < n; i++)
#define NYOOM ios::sync_with_stdio(0); cin.tie(0);
#define endl '\n'
const int INF = 1e9 + 7;
const ll LLINF = 1ll<<60;

const int maxn = 1e6 + 10;
int n, m, dp[3][3][maxn];
string s; 

int cnt(int mn, int mx, int rem){ // mn = min(l - p), mx = max(l - p)
    if (mn <= -3 || mx >= 3) return 0;
    if (rem <= 0) return 1;
    if (dp[-mn][mx][rem] != -1) return dp[-mn][mx][rem];
    int go_l = cnt(min(mn + 1, 0), mx + 1, rem - 1);
    int go_p = cnt(mn - 1, max(0, mx - 1), rem - 1);
    dp[-mn][mx][rem] = (go_l + go_p) % m;
    return dp[-mn][mx][rem];
}

signed main(){
    NYOOM;
    fill(&dp[0][0][0], &dp[0][0][0] + 3 * 3 * maxn, -1);
    cin >> n >> m;
    cin >> s;
    int re = 1, mn = 0, mx = 0;
    FOR(i, n){
        if (s[i] == 'L'){
            mn = min(0, mn + 1), mx = mx + 1;
            continue;
        }
        // cur is p
        int rem = n - i - 1;
        int go_l = cnt(min(mn + 1, 0), mx + 1, rem);
        mn = mn - 1, mx = max(0, mx - 1);
        re = (re + go_l) % m;
    }
    cout << re;
}

Compilation message

linear_garden.cpp: In function 'long long int cnt(long long int, long long int, long long int)':
linear_garden.cpp:25:33: error: no matching function for call to 'min(long long int, int)'
   25 |     int go_l = cnt(min(mn + 1, 0), mx + 1, rem - 1);
      |                                 ^
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:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
linear_garden.cpp:25:33: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   25 |     int go_l = cnt(min(mn + 1, 0), mx + 1, rem - 1);
      |                                 ^
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:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
linear_garden.cpp:25:33: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   25 |     int go_l = cnt(min(mn + 1, 0), mx + 1, rem - 1);
      |                                 ^
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:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
linear_garden.cpp:25:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   25 |     int go_l = cnt(min(mn + 1, 0), mx + 1, rem - 1);
      |                                 ^
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:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
linear_garden.cpp:25:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   25 |     int go_l = cnt(min(mn + 1, 0), mx + 1, rem - 1);
      |                                 ^
linear_garden.cpp:26:41: error: no matching function for call to 'max(int, long long int)'
   26 |     int go_p = cnt(mn - 1, max(0, mx - 1), rem - 1);
      |                                         ^
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:26:41: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   26 |     int go_p = cnt(mn - 1, max(0, mx - 1), rem - 1);
      |                                         ^
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:26:41: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   26 |     int go_p = cnt(mn - 1, max(0, mx - 1), rem - 1);
      |                                         ^
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:26:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   26 |     int go_p = cnt(mn - 1, max(0, mx - 1), rem - 1);
      |                                         ^
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:26:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   26 |     int go_p = cnt(mn - 1, max(0, mx - 1), rem - 1);
      |                                         ^
linear_garden.cpp: In function 'int main()':
linear_garden.cpp:39:31: error: no matching function for call to 'min(int, long long int)'
   39 |             mn = min(0, mn + 1), mx = mx + 1;
      |                               ^
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:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
linear_garden.cpp:39:31: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   39 |             mn = min(0, mn + 1), mx = mx + 1;
      |                               ^
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:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
linear_garden.cpp:39:31: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   39 |             mn = min(0, mn + 1), mx = mx + 1;
      |                               ^
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:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
linear_garden.cpp:39:31: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   39 |             mn = min(0, mn + 1), mx = mx + 1;
      |                               ^
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:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
linear_garden.cpp:39:31: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   39 |             mn = min(0, mn + 1), mx = mx + 1;
      |                               ^
linear_garden.cpp:44:37: error: no matching function for call to 'min(long long int, int)'
   44 |         int go_l = cnt(min(mn + 1, 0), mx + 1, rem);
      |                                     ^
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:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
linear_garden.cpp:44:37: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   44 |         int go_l = cnt(min(mn + 1, 0), mx + 1, rem);
      |                                     ^
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:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
linear_garden.cpp:44:37: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   44 |         int go_l = cnt(min(mn + 1, 0), mx + 1, rem);
      |                                     ^
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:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
linear_garden.cpp:44:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   44 |         int go_l = cnt(min(mn + 1, 0), mx + 1, rem);
      |                                     ^
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:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
linear_garden.cpp:44:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   44 |         int go_l = cnt(min(mn + 1, 0), mx + 1, rem);
      |                                     ^
linear_garden.cpp:45:40: error: no matching function for call to 'max(int, long long int)'
   45 |         mn = mn - 1, mx = max(0, mx - 1);
      |                                        ^
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:45:40: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   45 |         mn = mn - 1, mx = max(0, mx - 1);
      |                                        ^
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:45:40: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   45 |         mn = mn - 1, mx = max(0, mx - 1);
      |                                        ^
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:45:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   45 |         mn = mn - 1, mx = max(0, mx - 1);
      |                                        ^
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:45:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   45 |         mn = mn - 1, mx = max(0, mx - 1);
      |                                        ^