QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#275851#6410. Classical DP ProblemwangqingxianCompile Error//C++14782b2023-12-05 10:00:162023-12-05 10:00:17

Judging History

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

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

answer

#include<iostream>
#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;
}


詳細信息

answer.code: In function ‘int main()’:
answer.code:22:5: error: ‘reverse’ was not declared in this scope
   22 |     reverse(a+1,a+1+n);
      |     ^~~~~~~
answer.code:3:17: error: ‘memset’ was not declared in this scope
    3 | #define mem0(a) memset(a,0,sizeof(a))
      |                 ^~~~~~
answer.code:23:10: note: in expansion of macro ‘mem0’
   23 |     dp();mem0(a);
      |          ^~~~
answer.code:2:1: note: ‘memset’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’?
    1 | #include<iostream>
  +++ |+#include <cstring>
    2 | #define For(i,l,r) for(int i=(l);i<=(r);++i)