QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#659064#8049. Equal Sumsucup-team4992RE 0ms3600kbC++201.8kb2024-10-19 18:27:042024-10-19 18:27:04

Judging History

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

  • [2024-10-19 18:27:04]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3600kb
  • [2024-10-19 18:27:04]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

struct Segment{
    int l, r;
    Segment(int l = 0, int r = 0): l(l), r(r) {}
};

const int MAXN = 50+5;
const int M = 51;
const ll mod = 998244353;
int n, m;
ll sum[MAXN*2], dp[MAXN][MAXN][MAXN*2];
Segment sx[MAXN], sy[MAXN];

ll qry(int l, int r){
    if(l > r) return 0;
    // cout << "qry " << l << " " << r << "\n";
    return (sum[r+M] - sum[l+M-1] + mod) % mod;
}

int main(){
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        int l, r;
        cin >> l >> r;
        sx[i] = Segment(l, r);
    }
    for(int i = 1; i <= m; i++){
        int l, r;
        cin >> l >> r;
        sy[i] = Segment(l, r);
    }
    dp[0][0][M] = 1;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= m; j++){
            // cout << "i = " << i << " j = " << j << "\n";
            if(i == n && j == m) break;
            for(int k = -50; k <= 50; k++){
                sum[k+M] = (sum[k+M-1] + dp[i][j][k+M]) % mod;
                // cout << "dp " << i << " " << j << " " << k << " = " << dp[i][j][k+M] << "\n";
            }
            // cout << "\n";
            for(int k = -50; k <= 50; k++){
                // cout << "k = " << k << "\n";
                // cout << "qry " << max(-50, k-sx[i+1].r) << " " << min(0, k-sx[i+1].l) << " " << qry(max(-50, k-sx[i+1].r), min(0, k-sx[i+1].l)) << "\n";
                dp[i+1][j][k+M] = (dp[i+1][j][k+M] + qry(max(-50, k-sx[i+1].r), min(0, k-sx[i+1].l))) % mod;
                dp[i][j+1][k+M] = (dp[i][j+1][k+M] + qry(max(1, k+sy[j+1].l), min(50, k+sy[j+1].r))) % mod;
            }
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            cout << dp[i][j][0+M] << ' ';
        }
        cout << "\n";
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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
Runtime Error

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:


result: