QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#232919#6410. Classical DP Problembrianabucur10Compile Error//C++141.1kb2023-10-31 00:56:352023-10-31 00:56:35

Judging History

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

  • [2023-10-31 00:56:35]
  • 评测
  • [2023-10-31 00:56:35]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

int n, v[5005], a[5005], dp1[5005][5005], dp2[5005][5005], t, k;

long long fact (int n)
{
    int p=1;
    for (int i=2; i<=n; i++)
        p*=i;
}

void pd (int v[], int dp[][])
{
    dp[0][v[k+1]]=1;
    for (int i=1; i<=n; i++)
    {
        for (int j=0; j<k; j++)
        {
            dp[i+1][j]+=1LL*(v[i]-j)*dp[i][j];
            if (j>0)
                dp[i+1][j-1]+=1LL*j*dp[i][j];
        }
    }
}

void rotire ()
{
    for (int i=1; i<=n; i++)
    {
        for (int j=1; j<=n; j++)
        {
            if (v[j]>=i)
                a[i]++;
            else
                break;
        }
    }
}

int main()
{
    //9 1 1 2 5 6 6 6 7 9
    cin >> n;
    for (int i=1; i<=n; i++)
        cin >> v[n-i+1];
    for (int i=1; i<=n; i++)
    {
        bool ok=true;
        for (int j=1; j<=i; j++)
        {
            if (v[j]<i)
                ok=false;
        }
        if (!ok)
            break;
        else
            k=i;
    }
    rotire();
    pd(v,dp1);
    pd(a,dp2);
    int rez=dp1[n][k]+dp2[n][k]-fact(k);
    return 0;
}

Details

answer.code: In function ‘long long int fact(int)’:
answer.code:12:1: warning: no return statement in function returning non-void [-Wreturn-type]
   12 | }
      | ^
answer.code: At global scope:
answer.code:14:23: error: declaration of ‘dp’ as multidimensional array must have bounds for all dimensions except the first
   14 | void pd (int v[], int dp[][])
      |                       ^~
answer.code: In function ‘void pd(...)’:
answer.code:16:5: error: ‘dp’ was not declared in this scope; did you mean ‘pd’?
   16 |     dp[0][v[k+1]]=1;
      |     ^~
      |     pd