QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#682475#7875. Queue SortingWedonotLikeStudying#WA 3ms8652kbC++231.4kb2024-10-27 15:35:552024-10-27 15:35:55

Judging History

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

  • [2024-10-27 15:35:55]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:8652kb
  • [2024-10-27 15:35:55]
  • 提交

answer

#include<bits/stdc++.h>
#define rep(i,j,k) for (int i=(j);i<=(k);++i)
#define dep(i,j,k) for (int i=(j);i>=(k);--i)
#define MAXN 500
#define MOD 998244353
using namespace std;
typedef long long LL;

LL dp[MAXN+5][MAXN+5],sum[MAXN+5][MAXN+5];
int a[MAXN+5];
LL nCr[MAXN+5][MAXN+5];

void init() {
    nCr[0][0]=1;
    rep(i,1,MAXN) nCr[i][0]=1;
    rep(i,1,MAXN) {
        rep(j,1,i) {
            nCr[i][j]=(nCr[i-1][j-1]+nCr[i-1][j])%MOD;
        }
    }
    rep(i,0,MAXN) {
        rep(j,1,MAXN) {
            (nCr[i][j]+=nCr[i][j-1])%=MOD;
        }
    }
}

void solve() {
    init();
    int n;
    cin>>n;
    rep(i,1,n) cin>>a[i];
    int tot=0;
    dep(i,n,1) {
        if (!a[i]) {
            rep(j,1,tot+1) dp[i][j]=dp[i+1][j];
            continue;
        }
        tot+=a[i];
        dp[i][tot+1]=1;
        rep(j,2,tot) {
            if (j>a[i]) dp[i][j]=dp[i+1][j-a[i]];
            rep(k,max(1+j-a[i],2),tot-a[i]+1) {
                (dp[i][j]+=dp[i+1][k]*nCr[k+a[i]-j-1][a[i]-1]%MOD)%=MOD;
            }
        }
    }
    rep(i,1,n) {
        rep(j,1,tot+1)
            cout<<dp[i][j]<<" ";
        cout<<"\n";
    }
    LL ans=0;
    rep(i,1,tot+1) (ans+=dp[1][i])%=MOD;
    cout<<ans<<"\n";
    return;
}

int main() {
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t;
    // cin>>t;
    t=1;
    while (t--) solve();
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 8652kb

input:

4
1 1 1 1

output:

0 5 5 3 1 
0 2 2 1 0 
0 1 1 0 0 
0 1 0 0 0 
14

result:

wrong answer 1st numbers differ - expected: '14', found: '0'