QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#659082#8049. Equal Sumsucup-team4992WA 2017ms11544kbC++201.9kb2024-10-19 18:31:412024-10-19 18:31:43

Judging History

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

  • [2024-10-19 18:31:43]
  • 评测
  • 测评结果:WA
  • 用时:2017ms
  • 内存:11544kb
  • [2024-10-19 18:31:41]
  • 提交

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 = 500+5;
const int M = 501;
const ll mod = 998244353;
int n, m;
ll sum[MAXN*2], dp[2][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++){
        int now = i & 1, nxt = now ^ 1;
        for(int j = 0; j <= m; j++){
            for(int k = -500; k <= 500; k++){
                dp[nxt][j][k+M] = 0;
            }
        }
        for(int j = 0; j <= m; j++){
            if(i >= 1 && j >= 1){
                cout << dp[now][j][0+M] << " ";
            }
            if(i == n && j == m) break;
            for(int k = -500; k <= 500; k++){
                sum[k+M] = (sum[k+M-1] + dp[now][j][k+M]) % mod;
                // cout << "dp " << i << " " << j << " " << k << " = " << dp[i][j][k+M] << "\n";
            }
            // cout << "\n";
            for(int k = -500; k <= 500; 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[nxt][j][k+M] = (dp[nxt][j][k+M] + qry(max(-50, k-sx[i+1].r), min(0, k-sx[i+1].l))) % mod;
                dp[now][j+1][k+M] = (dp[now][j+1][k+M] + qry(max(1, k+sy[j+1].l), min(50, k+sy[j+1].r))) % mod;
            }
        }
        if(i >= 1){
            cout << "\n";
        }
    }
    return 0;
}

詳細信息

Test #1:

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

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: 2017ms
memory: 11544kb

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:

3 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: '3'