QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#478106#8049. Equal SumswcyQwQWA 979ms1005668kbC++141.2kb2024-07-14 17:08:272024-07-14 17:08:27

Judging History

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

  • [2024-07-14 17:08:27]
  • 评测
  • 测评结果:WA
  • 用时:979ms
  • 内存:1005668kb
  • [2024-07-14 17:08:27]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int N = 510, mod = 998244353;
int f[N][N][2 * N], lx[N], rx[N], ly[N], ry[N];

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

void dec(int &x, int y) {
  if ((x -= y) < 0) x += mod;
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> lx[i] >> rx[i];
  for (int i = 1; i <= m; i++) cin >> ly[i] >> ry[i];
  const int Z = 500;
  f[0][0][Z] = 1, f[0][0][Z + 1] = mod - 1;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      for (int k = 1; k <= 2 * Z; k++) {
        inc(f[i][j][k], f[i][j][k - 1]);
      }
      if (i < n) {
        for (int k = 0; k <= Z; k++) {
          inc(f[i + 1][j][k + lx[i + 1]], f[i][j][k]);
          dec(f[i + 1][j][k + rx[i + 1] + 1], f[i][j][k]);
        }
      }
      if (j < m) {
        for (int k = Z + 1; k <= 2 * Z; k++) {
          inc(f[i][j + 1][k - ry[j + 1]], f[i][j][k]);
          dec(f[i][j + 1][k - lx[j + 1] + 1], f[i][j][k]);
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cout << f[i][j][Z] << " \n"[j == m];
    }
  }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 979ms
memory: 1005668kb

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:

440 96580 13530384 901244960 466845747 404348148 559564568 858170166 337554513 689477673 480530434 373808828 482860313 808651713 904837004 464058609 51895935 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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: '440'