QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#763409#8049. Equal SumsGrain_Depot08WA 0ms4008kbC++17856b2024-11-19 20:07:592024-11-19 20:08:00

Judging History

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

  • [2024-11-19 20:08:00]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4008kb
  • [2024-11-19 20:07:59]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define mod 998244353
#define N 505
int n,m,f[N][N][N+N],a[N],b[N],x[N],y[N];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)scanf("%d%d",&a[i],&b[i]);
	for(int i=1;i<=m;++i){
		scanf("%d%d",&x[i],&y[i]);
		x[i]=-x[i];y[i]=-y[i];
		swap(x[i],y[i]);
	}
	f[0][0][N]=1;
	for(int i=0;i<=n;++i){
		for(int j=0;j<=m;++j){
			for(int k=-500;k<=500;++k){
				if(k>0){
					if(i)f[i][j][N+k]=((f[i][j][N+k]+f[i-1][j][N+k-a[i]])%mod-f[i-1][j][N+k-b[i]-1]+mod)%mod;
				}else{
					if(j)f[i][j][N+k]=((f[i][j][N+k]+f[i][j-1][N+k-x[j]])%mod-f[i][j-1][N+k-y[j]-1]+mod)%mod;
				}
			}
			for(int k=-500;k<=500;++k)
				f[i][j][N+k]=(f[i][j][N+k-1]+f[i][j][N+k])%mod;
		}
	}
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j)
			printf("%d ",f[i][j][N]);
		printf("\n");
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 4008kb

input:

2 3
1 2
2 3
1 4
2 2
1 3

output:

7 8 24 
4 12 47 

result:

wrong answer 1st numbers differ - expected: '2', found: '7'