QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#304383#7875. Queue Sortingucup-team134#WA 1ms3768kbC++17830b2024-01-13 18:50:522024-01-13 18:50:53

Judging History

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

  • [2024-01-13 18:50:53]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3768kb
  • [2024-01-13 18:50:52]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long

const int mod=998244353;
int add(int x,int y){x+=y;return x>=mod?x-mod:x;}
int sub(int x,int y){x-=y;return x<0?x+mod:x;}
int mul(int x,int y){return (ll)x*y%mod;}

const int N=505;
int a[N],sum[N];
int dp[2][N],pref[2][N];
int main(){
	int n;
	scanf("%i",&n);
	for(int i=1;i<=n;i++){
		scanf("%i",&a[i]);
		sum[i]=sum[i-1]+a[i];
	}
	int c=0,p=1;
	dp[c][0]=1;
	for(int i=0;i<=n;i++)pref[c][i]=1;
	for(int i=1;i<=sum[n];i++){
		swap(c,p);
		dp[c][0]=0;
		pref[c][0]=0;
		for(int j=1;j<=n;j++){
			if(a[j]==0){
				dp[c][j]=0;
			}else{
				dp[c][j]=pref[p][j-1];
				if(sum[j]>i-1){
					dp[c][j]=add(dp[c][j],dp[p][j]);
				}
			}
			pref[c][j]=add(pref[c][j-1],dp[c][j]);
		}
	}
	printf("%i\n",pref[c][n]);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
1 1 1 1

output:

14

result:

ok 1 number(s): "14"

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3768kb

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'