QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#478094#8049. Equal SumsmaojunWA 2ms10064kbC++23915b2024-07-14 16:45:212024-07-14 16:45:22

Judging History

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

  • [2024-07-14 16:45:22]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:10064kb
  • [2024-07-14 16:45:21]
  • 提交

answer

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

const int N=505,MOD=998244353;
int n,m,lx[N],rx[N],ly[N],ry[N];

int dp[N][N][N+N],g[N][N][N+N];
inline int add(int x,int y){x+=y;return x>=MOD?x-MOD:x;}
int main(){
	scanf("%d%d",&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]);
	fill(g[0][0]+N,g[0][0]+N+N,1);
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			if(j)for(int k=-500;k<0;k++)dp[i][j][N+k]=add(g[i][j-1][N+k+ry[j]],MOD-g[i][j-1][N+k+ly[j]-1]);
			if(i)for(int k=0;k<=500;k++)dp[i][j][N+k]=add(g[i-1][j][N+k-lx[i]],MOD-g[i-1][j][N+k-rx[i]-1]);
			if(i||j)for(int k=-500;k<=500;k++)g[i][j][N+k]=add(g[i][j][N+k-1],dp[i][j][N+k]);
			if(i&&j)printf("%d ",dp[i][j][N]);
		}
		if(i)puts("");
	}
	for(int i=0;i<=n;i++)for(int j=0;j<=m;j++){
		for(int k=-10;k<=10;k++)printf("%d ",g[i][j][N+k]);
		puts("");
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 10064kb

input:

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

output:

2 0 0 
3 4 4 
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 
0 0 0 0 0 0 1 2 3 4 4 4 4 4 4 4 4 4 4 4 4 
0 0 0 0 1 2 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 
0 1 3 6 9 11 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 
0 0 0 0 0 0 0 0 0 0 0 1 2 2 2 2 2 2 2 2 2 
0 0 0 0 0 0 0 1 3 5 7 8 8 8 8 8 8 8 8 8 8 
0 0 0 0 0 1 ...

result:

wrong answer Output contains longer sequence [length = 258], but answer contains 6 elements