QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#232930#6410. Classical DP Problembrianabucur10Compile Error//C++141.5kb2023-10-31 01:20:012023-10-31 01:20:01

Judging History

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

  • [2023-10-31 01:20:01]
  • 评测
  • [2023-10-31 01:20:01]
  • 提交

answer

#include <bits/stdc++.h>
#define <NMAX> 998244353;

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;
        p%=NMAX;
    }
    return p%NMAX;
}

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

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);
    //cout << dp1[k][0] << " " << dp2[k][0];
    long long rez=(dp1[k][0]%NMAX+dp2[k][0]%NMAX-1LL*fact(k)%NMAX)%NMAX;
    cout << k << " " << 1LL*rez%NMAX;
    return 0;
}

详细

answer.code:2:9: error: macro names must be identifiers
    2 | #define <NMAX> 998244353;
      |         ^
answer.code: In function ‘long long int fact(int)’:
answer.code:14:12: error: ‘NMAX’ was not declared in this scope
   14 |         p%=NMAX;
      |            ^~~~
answer.code:16:14: error: ‘NMAX’ was not declared in this scope
   16 |     return p%NMAX;
      |              ^~~~
answer.code: In function ‘void pd(int*, int (*)[5005])’:
answer.code:27:50: error: ‘NMAX’ was not declared in this scope
   27 |             dp[i+1][j]+=1LL*(v[i+1]-j)*dp[i][j]%=NMAX;
      |                                                  ^~~~
answer.code: In function ‘int main()’:
answer.code:75:30: error: ‘NMAX’ was not declared in this scope
   75 |     long long rez=(dp1[k][0]%NMAX+dp2[k][0]%NMAX-1LL*fact(k)%NMAX)%NMAX;
      |                              ^~~~