QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#398287#8049. Equal SumscqbzlyWA 2804ms15524kbC++141.7kb2024-04-25 10:24:352024-04-25 10:24:35

Judging History

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

  • [2024-04-25 10:24:35]
  • 评测
  • 测评结果:WA
  • 用时:2804ms
  • 内存:15524kb
  • [2024-04-25 10:24:35]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define db double
#define fi first
#define se second
#define vi vector<int>
#define inf 0x3f3f3f3f
using namespace std;
const int N=505;
const int mod=998244353;
int n,m,lim,l1[N],r1[N],l2[N],r2[N];
ll f[N][N<<1],g[N][N<<1],h[N][N<<1];
void add(ll &x,ll y){
    x=(x+y)%mod;
}
signed main(){
    //freopen("data.in","r",stdin);
    // freopen("own.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>l1[i]>>r1[i],lim=max(lim,r1[i]);
    for(int i=1;i<=m;i++)cin>>l2[i]>>r2[i],lim=max(lim,r2[i]);
    f[0][lim]=1;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            for(int k=0;k<=lim<<1;k++){
                g[j][k]=h[j][k]=0;
            }
        }
        for(int j=0;j<=m;j++){
            for(int k=0;k<=lim<<1;k++){
                if(k)g[j][k]=(g[j][k]+g[j][k-1])%mod;
                f[j][k]=(f[j][k]+g[j][k])%mod;
                if(!f[j][k])continue;
                //cout<<"find:"<<i<<" "<<j<<" "<<k<<" "<<f[j][k]<<"\n";
                if(k<=lim&&i<n){
                    add(h[j][k+l1[i+1]],f[j][k]);
                    add(h[j][k+r1[i+1]+1],-f[j][k]);
                }
                if(k>lim&&j<m){
                    add(g[j+1][k-r2[j+1]],f[j][k]);
                    add(g[j+1][k-l2[j+1]+1],-f[j][k]);
                }
            }
            if(i&&j)cout<<f[j][lim]<<" ";
        }
        for(int j=0;j<=m;j++){
            for(int k=0;k<=lim<<1;k++){
                if(k)h[j][k]=(h[j][k]+h[j][k-1])%mod;
                f[j][k]=h[j][k];
            }
        }
        if(i)cout<<"\n";
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 2804ms
memory: 15524kb

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 -817663288 984223118 -411655119 293043270 -593880557 865361724 -332756365 118838806 -72054409 226338288 -476764496 808644951 -212203065 340769021 -998067253 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 ...

result:

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