QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#682213#7875. Queue SortingWedonotLikeStudying#WA 0ms9516kbC++231.0kb2024-10-27 14:27:302024-10-27 14:27:31

Judging History

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

  • [2024-10-27 14:27:31]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:9516kb
  • [2024-10-27 14:27:30]
  • 提交

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;
        }
    }
}

void solve() {
    init();
    int n;
    cin>>n;
    rep(i,1,n) cin>>a[i];
    int tot=0;
    dep(i,n,1) {
        tot+=a[i];
        dp[i][tot+1]=1;
        rep(j,a[i]+1,tot) {
            dp[i][j]=(dp[i+1][j-a[i]]+nCr[j-1][a[i]-1]*sum[i+1][j-a[i]+1]%MOD)%MOD;
        }
        dep(j,tot+1,1) {
            sum[i][j]=(sum[i][j+1]+dp[i][j])%MOD;
        }
    }
    cout<<sum[1][1]<<"\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: 100
Accepted
time: 0ms
memory: 8916kb

input:

4
1 1 1 1

output:

14

result:

ok 1 number(s): "14"

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 9516kb

input:

300
0 5 2 2 1 0 3 2 2 5 2 1 1 2 1 3 2 3 2 0 0 0 0 1 2 2 3 0 2 2 3 2 0 2 3 0 6 0 0 2 0 1 3 2 1 1 1 3 4 0 1 0 4 1 1 1 1 1 1 2 3 2 1 2 3 2 3 0 5 3 3 2 0 1 1 0 2 1 1 2 0 0 2 1 1 3 2 2 1 2 1 3 0 3 0 1 2 2 0 5 0 2 2 0 0 0 1 2 1 4 2 1 1 0 3 0 2 0 3 1 1 2 0 2 1 1 0 2 0 1 2 2 3 3 1 1 1 1 0 1 3 3 1 0 2 2 4 2 ...

output:

955480983

result:

wrong answer 1st numbers differ - expected: '507010274', found: '955480983'