QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#271818 | #7875. Queue Sorting | ucup-team1321# | WA | 89ms | 4616kb | C++20 | 873b | 2023-12-02 14:43:26 | 2023-12-02 14:43:26 |
Judging History
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;
for (int i=1;i<=n;i++) cin>>a[i];
g[0][0]=1;
for (int i=1;i<=n;i++) {
g[i][0]=1;
for (int j=1;j<=n;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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3440kb
input:
4 1 1 1 1
output:
14
result:
ok 1 number(s): "14"
Test #2:
score: -100
Wrong Answer
time: 89ms
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'