QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#337457 | #8049. Equal Sums | FISHER_ | WA | 969ms | 995168kb | C++20 | 1.1kb | 2024-02-25 12:13:03 | 2024-02-25 12:13:03 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
inline int Mod(int x) { return x + ((x >> 31) & mod); }
inline int add(int x, int y) { return Mod(x + y - mod); }
inline int sub(int x, int y) { return Mod(x - y); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
const int maxn = 500;
int l[maxn + 5], r[maxn + 5], L[maxn + 5], R[maxn + 5];
int f[maxn + 5][maxn + 5][2 * maxn + 5];
inline int q(int i, int j, int l, int r) {
if (j < 0 || l > r) return 0;
return sub(f[i][j][r], f[i][j][l - 1]);
}
int main() {
int n, m;
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++) scanf("%d%d", &l[i], &r[i]);
for (int i = 1; i <= m; i++) scanf("%d%d", &L[i], &R[i]);
fill(f[0][0] + 501, f[0][0] + 1002, 1);
for (int i = 1; i <= n; i++) {
for (int j = 0; j <= m; j++)
for (int k = 1; k <= 1001; k++) {
f[i][j][k] = add(q(i - 1, j, k - r[i], min(k - l[i], 501)), q(i, j - 1, max(k + L[j], 502), k + R[j]));
if (j && k == 501) printf("%d ", f[i][j][k]);
f[i][j][k] = add(f[i][j][k], f[i][j][k - 1]);
}
puts("");
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 7992kb
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: 969ms
memory: 995168kb
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 302196030 360844192 845433506 447912599 623006376 149752333 450082966 397882413 567258658 544339478 366416214 441300113 154653811 546623325 475088104 355143898 228698038 477262513 383355813 769982171 128968276 411512027 939651762 352793465 722739288 983176061 74661294 959488906 139848677 9049300...
result:
wrong answer 2nd numbers differ - expected: '79401', found: '302196030'