QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#271837#7875. Queue Sortingucup-team1321#WA 164ms4616kbC++20898b2023-12-02 14:49:382023-12-02 14:49:40

Judging History

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

  • [2023-12-02 14:49:40]
  • 评测
  • 测评结果:WA
  • 用时:164ms
  • 内存:4616kb
  • [2023-12-02 14:49:38]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int Mod=998244353;
int n,g[510][510],f[510][510],a[510];
int main() {
    
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n;
    int m=0; 
    for (int i=1;i<=n;i++) cin>>a[i],m+=a[i];
    g[0][0]=1;
    for (int i=1;i<=n;i++) {
        g[i][0]=1;
        for (int j=1;j<=500;j++) 
          for (int k=0;k<=j;k++)
            g[i][j]+=g[i-1][j-k],g[i][j]%=Mod;
    }
    int s=0;
    f[0][0]=1;
    for (int i=1;i<=n;i++) {
        for (int j=0;j<=s;j++) {
            for (int k=j;k<s;k++) 
              for (int t=0;t<a[i];t++)
                f[i][k+1+t]=(f[i][k+1+t]+1LL*f[i-1][j]*g[k-j+1][t]%Mod)%Mod;
            f[i][j]+=f[i-1][j];f[i][j]%=Mod;
        }
        s+=a[i];
    }
    int ans=0;
    for (int i=0;i<s;i++) ans=(ans+f[n][i])%Mod; 
      cout<<ans;
    return 0;
          
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3444kb

input:

4
1 1 1 1

output:

14

result:

ok 1 number(s): "14"

Test #2:

score: -100
Wrong Answer
time: 164ms
memory: 4616kb

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:

99545473

result:

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