QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#275852#6410. Classical DP ProblemwangqingxianCompile Error//C++14822b2023-12-05 10:00:502023-12-05 10:00:50

Judging History

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

  • [2023-12-05 10:00:50]
  • 评测
  • [2023-12-05 10:00:50]
  • 提交

answer

#include<iostream>
#include<cstrinf>
#include<algorithm>
#define For(i,l,r) for(int i=(l);i<=(r);++i)
#define mem0(a) memset(a,0,sizeof(a))
#define int long long
using namespace std;
const int N=5e3+10,mod=998244353;
int n,a[N],k,f[N][N],g[N],tim=1,ans=0,temp[N];
void dp(){
    For(i,1,n)k=max(k,min(a[i],i));
    int t=a[k+1];
    f[0][0]=1;
    For(i,1,k)
        For(j,0,t){
            if(j)f[i][j]=f[i-1][j-1]*(t-j+1)%mod;
            f[i][j]=(f[i][j]+f[i-1][j]*(a[i]-(t-j))%mod)%mod;
        }
    ans+=f[k][t];
}
signed main(){
    cin>>n;
    For(i,1,n){cin>>a[i];temp[i]=a[i];}
    reverse(a+1,a+1+n);
    dp();mem0(a);
    For(i,1,temp[n])For(j,1,n)if(temp[j]>=i) a[i]++;
    mem0(f);dp();
    For(i,1,k)tim=tim*i%mod;
    cout<<k<<" "<<(ans-tim+mod)%mod<<endl;
    return 0;
}


Details

answer.code:2:9: fatal error: cstrinf: No such file or directory
    2 | #include<cstrinf>
      |         ^~~~~~~~~
compilation terminated.