QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#440281#8049. Equal Sumsrotcar07WA 30ms11584kbC++14869b2024-06-13 15:11:272024-06-13 15:11:28

Judging History

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

  • [2024-06-13 15:11:28]
  • 评测
  • 测评结果:WA
  • 用时:30ms
  • 内存:11584kb
  • [2024-06-13 15:11:27]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
constexpr int N=505;
int n,m,a[N],b[N],c[N],d[N];
typedef long long ll;
constexpr ll mod=998244353;
int sum[2][N][N*2],dp[2][N][N*2];
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i]>>b[i];
    for(int i=1;i<=m;i++) cin>>c[i]>>d[i];
    const int D=5;
    dp[0][0][D]=1;
    ll ans=0;
    for(int k=D;k<=2*D;k++) sum[0][0][k]=1;
    for(int i=0;i<=n;i++,cout<<'\n')
    for(int j=0;j<=m;j++)if(i||j)
    for(int k=1;k<=2*D;k++){
        auto&r=dp[i&1][j][k];r=0;
        if(i) r+=sum[i&1^1][j][max(0,min(D-1,k-a[i]))]-sum[i&1^1][j][min(D-1,max(0,k-b[i]-1))],r%=mod;
        if(j) r+=sum[i&1][j-1][max(D-1,min(2*D,k+d[j]))]-sum[i&1][j-1][min(2*D,max(D,k+c[j])-1)],r%=mod;
        r=(r%mod+mod)%mod;
        sum[i&1][j][k]=(sum[i&1][j][k-1]+r)%mod;
		if(k==D&&i&&j) cout<<r<<' ';
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 30ms
memory: 11584kb

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:


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 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 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 1st numbers differ - expected: '411', found: '0'