QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#627504#8049. Equal SumsxhguaWA 139ms998056kbC++141.2kb2024-10-10 16:09:432024-10-10 16:09:45

Judging History

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

  • [2024-10-10 16:09:45]
  • 评测
  • 测评结果:WA
  • 用时:139ms
  • 内存:998056kb
  • [2024-10-10 16:09:43]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;

constexpr int N = 5e2 + 5, S = 20, P = 998244353;

int n, m, lx[N], rx[N], ly[N], ry[N], f[N][N][N * 2];

void add(int &x, int y) { 
    x += y;
    if (x >= P) x -= P;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    std::cin >> n >> m;
    for (int i = 1; i <= n; i++) std::cin >> lx[i] >> rx[i];
    for (int i = 1; i <= m; i++) std::cin >> ly[i] >> ry[i];
    f[0][0][S] = 1, f[0][0][S + 1] = P - 1;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            for (int k = -S; k <= S; k++) {
                if (k != -S) add(f[i][j][k + S], f[i][j][k - 1 + S]);
                if (k < 0) {
                    add(f[i + 1][j][k + lx[i + 1] + S], f[i][j][k + S]);
                    add(f[i + 1][j][k + rx[i + 1] + S + 1], P - f[i][j][k + S]);
                }
                else {
                    add(f[i][j + 1][k - ry[j + 1] + S], f[i][j][k + S]);
                    add(f[i][j + 1][k - ly[j + 1] + S + 1], P - f[i][j][k + S]);
                }
            }
            if (i && j) std::cout << f[i][j][S] << " ";
        }
        if (i) std::cout << "\n";
    }
    return 0;
}

详细

Test #1:

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

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: 139ms
memory: 998056kb

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'