QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#763367#8049. Equal SumsGrain_Depot08WA 0ms5904kbC++141.2kb2024-11-19 19:50:232024-11-19 19:50:24

Judging History

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

  • [2024-11-19 19:50:24]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:5904kb
  • [2024-11-19 19:50:23]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define mod 998244353
#define N 505
int n,m,f[N][N][N+N],s[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]);
		int u=x[i],v=y[i];
		x[i]=-v;y[i]=-u;
	}
	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&&b[i]>=max(k,a[i])){
						f[i][j][N+k]=((f[i][j][N+k]+s[i-1][j][N+k-max(k,a[i])])%mod-s[i-1][j][N+k-b[i]-1]+mod)%mod;
					}
					if(j&&y[j]>=max(k,x[j])){
						f[i][j][N+k]=((f[i][j][N+k]+s[i][j-1][N+k-max(k,x[j])])%mod-s[i][j-1][N+k-y[j]-1]+mod)%mod;
					}
				}else{
					if(i&&min(b[i],k-1)>=a[i]){
						f[i][j][N+k]=((f[i][j][N+k]+s[i-1][j][N+k-a[i]])%mod-s[i-1][j][N+k-min(b[i],k-1)-1]+mod)%mod;
					}
					if(j&&min(y[j],k-1)>=x[j]){
						f[i][j][N+k]=((f[i][j][N+k]+s[i][j-1][N+k-x[j]])%mod-s[i][j-1][N+k-min(y[j],k-1)-1]+mod)%mod;
					}
				}
			}
			for(int k=-500;k<=500;++k)
				s[i][j][N+k]=(s[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: 5904kb

input:

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

output:

2 0 0 
0 4 0 

result:

wrong answer 4th numbers differ - expected: '3', found: '0'