QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#278763 | #7875. Queue Sorting | ucup-team073# | WA | 22ms | 5656kb | C++20 | 602b | 2023-12-07 20:20:27 | 2023-12-07 20:20:28 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
constexpr int mod=998244353;
int a[510],sum[510],f[510][510],n,m;
signed main(){
cin>>n;
for(int i=1;i<=n;++i)cin>>a[i],sum[i]=sum[i-1]+a[i],m+=a[i];
for(int i=1;i<=n;++i)if(a[i])f[1][i]=1;
for(int i=2;i<=m;++i){
for(int j=1;j<=n;++j){
for(int k=j;k<=n;++k){
if(!a[k])continue;
if(k==j&&i>sum[j])continue;
f[i][k]=(f[i][k]+f[i-1][j])%mod;
}
}
}
//for(int i=1;i<=m;++i)for(int j=1;j<=n;++j)cout<<i<<' '<<j<<' '<<f[i][j]<<endl;
cout<<f[m][n];
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3564kb
input:
4 1 1 1 1
output:
14
result:
ok 1 number(s): "14"
Test #2:
score: -100
Wrong Answer
time: 22ms
memory: 5656kb
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:
743572928
result:
wrong answer 1st numbers differ - expected: '507010274', found: '743572928'