QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#478095#8049. Equal SumsmaojunML 0ms10076kbC++23797b2024-07-14 16:45:312024-07-14 16:45:31

Judging History

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

  • [2024-07-14 16:45:31]
  • 评测
  • 测评结果:ML
  • 用时:0ms
  • 内存:10076kb
  • [2024-07-14 16:45:31]
  • 提交

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("");
	}
	return 0;
}

詳細信息

Test #1:

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

input:

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

output:

2 0 0 
3 4 4 

result:

ok 6 numbers

Test #2:

score: -100
Memory Limit Exceeded

input:

500 500
19 458
1 480
7 485
50 461
12 476
15 461
48 466
40 453
46 467
9 458
27 478
26 472
46 459
29 490
6 500
17 487
48 484
28 472
28 459
25 480
4 491
29 481
36 460
2 491
44 499
22 473
20 458
4 483
27 471
2 496
11 461
43 450
2 478
37 466
15 459
42 482
7 451
19 455
2 453
47 475
48 450
1 474
46 471
9 4...

output:

411 79401 9145270 673005095 180581065 984223118 586589234 293043270 404363796 865361724 665487988 118838806 926189944 226338288 521479857 808644951 786041288 340769021 177100 21 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result: