QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#767454#8049. Equal Sumsroger_yrjWA 0ms3856kbC++14985b2024-11-20 21:00:052024-11-20 21:00:05

Judging History

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

  • [2024-11-20 21:00:05]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3856kb
  • [2024-11-20 21:00:05]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=510,mod=998244353,V=500;
int n,m,lx[N],rx[N],ly[N],ry[N],f[N][N][N<<1];
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)scanf("%d%d",&lx[i],&rx[i]);
	for(int i=1;i<=m;i++)scanf("%d%d",&ly[i],&ry[i]);
	f[0][0][V]=1;
	f[0][0][V+1]=-1;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			for(int k=0;k<=V*2;k++){
				if(k>0)f[i][j][k]=(1ll*f[i][j][k]+f[i][j][k-1])%mod;
				if(k<=V&&i<n){
					if(k+lx[i+1]<=2*V)f[i+1][j][k+lx[i+1]]=(1ll*f[i+1][j][k+lx[i+1]]+f[i][j][k])%mod;
					if(k+rx[i+1]+1<=2*V)f[i+1][j][k+rx[i+1]+1]=(1ll*f[i+1][j][k+rx[i+1]+1]-f[i][j][k]+mod)%mod;
				}else if(k>V&&j<m){
					f[i][j+1][max(0,k-ry[j+1])]=(1ll*f[i][j+1][max(0,k-ry[j+1])]+f[i][j][k])%mod;
					f[i][j+1][max(0,k-ly[j+1]+1)]=(1ll*f[i][j+1][max(0,k-ly[j+1]+1)]-f[i][j][k]+mod)%mod;
				}
			}
		}
	}
	cout<<f[1][1][V-2]<<"\n";
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++)cout<<f[i][j][V]<<" ";
		cout<<"\n";
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

2
2 0 0 
3 4 4 

result:

wrong answer 2nd numbers differ - expected: '0', found: '2'