QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#584728#8049. Equal SumsJessica2333WA 1883ms11676kbC++141.4kb2024-09-23 16:25:432024-09-23 16:25:43

Judging History

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

  • [2024-09-23 16:25:43]
  • 评测
  • 测评结果:WA
  • 用时:1883ms
  • 内存:11676kb
  • [2024-09-23 16:25:43]
  • 提交

answer

#include<iostream>
#include<cstring>
#define int long long
using namespace std;
const int MOD=998244353;
int N,M,L[2][508],R[2][508];
int f[508][1008],g[508][1008],h[1008];
const int O=500;
signed main()
{
//	bool flag=0;
	cin>>N>>M;
	for(int i=1;i<=N;i++) cin>>L[0][i]>>R[0][i];
	for(int i=1;i<=M;i++) cin>>L[1][i]>>R[1][i];
	g[0][O]=1;g[0][O+1]=-1;
	for(int i=0;i<=N;i++)
	{
		for(int j=0;j<=M;j++)
		{
			f[j][0]=g[j][0];g[j][0]=0;
			for(int k=1;k<=O+500;k++) (g[j][k]+=g[j][k-1])%=MOD,f[j][k]=g[j][k];
			for(int k=0;k<=O+500;k++) g[j][k]=0;
		}
		for(int j=0;j<=M;j++)
		{
			for(int k=0;k<=O+500;k++)
			{
				if(k) (h[k]+=h[k-1])%MOD;
				f[j][k]+=h[k];
			}
			memset(h,0,sizeof(h));
			for(int k=0;k<=O+500;k++)
			{
//				if(f[j][k]) flag=1;else flag=0;
//				if(flag) cout<<"f "<<i<<" "<<j<<" "<<k-O<<"="<<f[j][k]<<"\n";
				if(k<=O)
				{
//					if(flag) cout<<k+L[0][i+1]-O<<" "<<k+R[0][i+1]+1-O<<"*\n";
					(g[j][min(k+L[0][i+1],O+501)]+=f[j][k])%=MOD,(g[j][min(k+R[0][i+1]+1,O+501)]-=f[j][k])%=MOD;
				}
				else
				{
//					if(flag) cout<<k-R[1][j+1]-O<<" "<<k-L[1][j+1]+1-O<<"!\n";
					(h[max(k-R[1][j+1],0ll)]+=f[j][k])%=MOD,(h[max(k-L[1][j+1]+1,0ll)]-=f[j][k])%MOD;
//					(f[j+1][max(k-R[1][j+1],0ll)]+=f[j][k])%=MOD,(f[j+1][max(k-L[1][j+1]+1,0ll)]-=f[j][k])%MOD;
				}
			}
			if(i>0&&j>0) cout<<f[j][O]<<" ";
		}
		if(i) cout<<"\n";
	}
	return 0;
}
//白鸟惊飞久不栖

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 1883ms
memory: 11676kb

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 34120889067 95817436653 -173107928188 121080609983 -129367402094 -12541115771 -25405016974 24155960011 35471151759 6568013776 3778482630 2400143400 -15740622535 8011245191 23876375117 19519102300 36766690721 5442300219 7988214470 39165154391 -9752267357 -17012935243 -8551...

result:

wrong answer 5th numbers differ - expected: '180581065', found: '34120889067'