QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#271802#7875. Queue Sortingucup-team2279#WA 37ms6460kbC++201.2kb2023-12-02 14:38:592023-12-02 14:38:59

Judging History

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

  • [2023-12-02 14:38:59]
  • 评测
  • 测评结果:WA
  • 用时:37ms
  • 内存:6460kb
  • [2023-12-02 14:38:59]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mk make_pair
#define lowbit(x) (x&(-x))
#define pb emplace_back
#define pr pair<int,int>
#define let const auto
#define all(A) A.begin(),A.end()
const int N=505,mod=998244353;
int read(){
	int x=0,f=1; char c=getchar();
	while(('0'>c||c>'9')&&c!='-') c=getchar();
	if(c=='-') f=0,c=getchar();
	while('0'<=c&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return f?x:-x;
}
int C[N][N],n,a[N],pre[N][N];
int f[N][N];
int main(){
	n=read();
	for(int i=1; i<=n; i++) a[i]=read();
	for(int i=0; i<=n; i++){
		C[i][0]=pre[i][0]=1;
		for(int j=1; j<=i; j++) C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod,pre[i][j]=(pre[i][j-1]+C[i][j])%mod;
	}
	int sum=a[1];
	f[1][0]=1;
	auto calc = [&](int n,int l,int r){
		if(l>r) return 0;
		return (pre[n][r]-(l?pre[n][l-1]:0)+mod)%mod;
	};
	for(int i=2; i<=n; sum+=a[i],i++){
		for(int j=0; j<sum; j++)
			for(int k=j; k<sum+a[i]; k++){
				if(k==j) f[i][k]=(f[i][k]+f[i-1][j])%mod;
				else if(a[i])
					f[i][k]=(f[i][k]+1ll*f[i-1][j]*calc(k-j-1,k-j-a[i],min(k-j-1,sum-j-1)))%mod;
			}
	}
	printf("%lld\n",accumulate(f[n],f[n]+sum+1,0ll)%mod);
	return 0;
}

详细

Test #1:

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

input:

4
1 1 1 1

output:

14

result:

ok 1 number(s): "14"

Test #2:

score: -100
Wrong Answer
time: 37ms
memory: 6460kb

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:

0

result:

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