QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#453528#8049. Equal Sumsucup-team3282WA 1229ms11624kbC++141.6kb2024-06-23 23:06:482024-06-23 23:06:49

Judging History

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

  • [2024-06-23 23:06:49]
  • 评测
  • 测评结果:WA
  • 用时:1229ms
  • 内存:11624kb
  • [2024-06-23 23:06:48]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=510;
const int mod=998244353;
const int maxv=500;

int n,m;
int la[maxn],ra[maxn],lb[maxn],rb[maxn];
int f[2][maxn][maxv*2+10],s[2][maxn][maxv*2+10];

int pls(int x,int y){
	return x+y<mod?x+y:x+y-mod;
}

int main(){
	ios::sync_with_stdio(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>la[i]>>ra[i];
	for(int j=1;j<=m;j++)
		cin>>lb[j]>>rb[j];
	
	for(int k=-maxv;k<=maxv;k++){
		if(la[1]<=k&&k<=ra[1])
			f[1][0][k+maxv+1]=1;
		s[1][0][k+maxv+1]=pls(s[1][0][k-1+maxv+1],f[1][0][k+maxv+1]);
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
//			cout<<"---------------------"<<i<<' '<<j<<"---------------------"<<endl;
			for(int k=-maxv;k<=maxv;k++){
				f[i&1][j][k]=0;
				if(k<=ra[i] && k-max(k,la[i])>=-maxv){
//					cout<<'\t'<<max(k-ra[i],-maxv)<<"~"<<k-max(k,la[i])<<" -> "<<k<<endl;
					f[i&1][j][k+maxv+1]=pls(pls(mod-s[i&1^1][j][max(k-ra[i],-maxv)-1 +maxv+1],
					                        s[i&1^1][j][k-max(k,la[i])+maxv+1]),f[i&1][j][k+maxv+1]);
				}
				if(-k+1<=rb[j] && k+max(-k+1,lb[j])<=maxv){
//					cout<<'\t'<<k+max(-k+1,lb[j])<<"~"<<min(k+rb[j],maxv)<<" -> "<<k<<endl;
					f[i&1][j][k+maxv+1]=pls(pls(mod-s[i&1][j-1][k+max(-k+1,lb[j])-1 +maxv+1],
					                        s[i&1][j-1][min(k+rb[j],maxv) +maxv+1]),f[i&1][j][k+maxv+1]);
				}
//				cout<<"f "<<i<<' '<<j<<' '<<k<<' '<<f[i&1][j][k+maxv+1]<<endl;
				s[i&1][j][k+maxv+1]=pls(s[i&1][j][k-1+maxv+1],f[i&1][j][k+maxv+1]);
			}
			cout<<f[i&1][j][maxv+1]<<' ';
		}
		cout<<endl;
	}
	
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3716kb

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
Wrong Answer
time: 1229ms
memory: 11624kb

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:

wrong answer 1001st numbers differ - expected: '13811799', found: '13812621'