QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#232907#6410. Classical DP ProblemteamariaaCompile Error//C++141.7kb2023-10-31 00:31:112023-10-31 00:31:12

Judging History

你现在查看的是最新测评结果

  • [2023-10-31 00:31:12]
  • 评测
  • [2023-10-31 00:31:11]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int mod = 998244353;

int n, k, extra, answer;
vector <long long> len, height;

/// PUNE MODUL

long long solve(vector <long long> &v)
{
    vector <vector <long long> > dp;
    dp.assign(k + 1, vector <long long> (extra + 1));

    dp[0][extra] = 1;
    for(long long i = 0; i < k; i ++)
    {
        for(long long j = extra; j >= 0; j --)
        {
            dp[i + 1][j] += 1ll *((v[i + 1] - j) * dp[i][j]) % mod;
            dp[i + 1][j] %= mod;
            if(j > 0)
            {
                dp[i + 1][j - 1] += (j * dp[i][j]) % mod;
                dp[i + 1][j - 1] %= mod;
            }
        }
    }
    return dp[k][0];
}

long long fact(long long x)
{
    long long ans = 1;
    for(long long i = 2; i <= x; i ++)
        ans = (1ll * ans * i) % mod;
    return ans;
}

int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);

    cin >> n;
    len.resize(n); ///mortii masii
    height.resize(n + 1);

    for(long long i = 0; i < n; i ++)
        cin >> len[i];

    len.push_back(0);
    reverse(len.begin(), len.end());

    k = -1;
    for(long long i = 1; i <= n; i ++)
        k = max(k, min(len[i], i));

    cout << k << " ";

    for(long long i = 1; i <= n; i ++)
        for(long long j = 1; j <= len[i]; j ++)
            height[j] ++;


    extra = len[k + 1];
    answer = solve(len);

    extra = height[k + 1];
    answer += solve(height);
    answer %= mod;

    answer -= fact(k);
    answer %= mod;

    cout << answer;
    return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:62:16: error: no matching function for call to ‘max(int&, const long long int&)’
   62 |         k = max(k, min(len[i], i));
      |             ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/char_traits.h:39,
                 from /usr/include/c++/11/ios:40,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
answer.code:62:16: note:   deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘long long int’)
   62 |         k = max(k, min(len[i], i));
      |             ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/char_traits.h:39,
                 from /usr/include/c++/11/ios:40,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
answer.code:62:16: note:   deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘long long int’)
   62 |         k = max(k, min(len[i], i));
      |             ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)’
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
answer.code:62:16: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘int’
   62 |         k = max(k, min(len[i], i));
      |             ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)’
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
answer.code:62:16: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘int’
   62 |         k = max(k, min(len[i], i));
      |             ~~~^~~~~~~~~~~~~~~~~~~