QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#280038#7875. Queue SortingMurphy_WA 52ms7224kbC++14923b2023-12-09 13:30:112023-12-09 13:30:11

Judging History

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

  • [2023-12-09 13:30:11]
  • 评测
  • 测评结果:WA
  • 用时:52ms
  • 内存:7224kb
  • [2023-12-09 13:30:11]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define il inline
#define mod 998244353
#define N 512
using namespace std;
ll c[N][N],f[N][N],a[N],ans,t,n;
void init() {
	for(int i=0;i<N;++i) c[i][0]=c[i][1]=c[i][i]=1;
	for(int i=3;i<N;++i) for(int j=2;j<i;++j) c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
}
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;++i) scanf("%lld",&a[i]);
	init();
	f[0][0]=1;
	for(int i=1;i<=n;++i) {
		for(int j=0;j<=t;++j) f[i][j]=f[i-1][j];
		for(int j=0;j<t;++j) {
			for(int k=j;k<t;++k) {
				for(int l=0;l<a[i];++l) {
//					cout<<i<<' '<<j<<' '<<k<<' '<<l<<':'<<i<<' '<<k+l+1<<','<<i-1<<' '<<j<<','<<k-j+l<<' '<<l<<endl;
					f[i][k+l+1]=(f[i-1][j]*c[k-j+l][l]%mod+f[i][k+l+1])%mod;
				}
			}
		}
		t+=a[i];
	}
//	for(int i=1;i<=n;++i) {for(int j=0;j<=t;++j) cout<<f[i][j]<<' ';cout<<endl;}
	for(int j=0;j<t;++j) ans=(ans+f[n][j])%mod;
	cout<<ans;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 6132kb

input:

4
1 1 1 1

output:

14

result:

ok 1 number(s): "14"

Test #2:

score: -100
Wrong Answer
time: 52ms
memory: 7224kb

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:

702838008

result:

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