QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#764796 | #8049. Equal Sums | SkyMaths | WA | 1075ms | 1006092kb | C++14 | 2.6kb | 2024-11-20 10:43:02 | 2024-11-20 10:43:14 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
namespace Main {
#define ll long long
#define rep(i,l,r) for (int i(l), i##end(r); i <= i##end; ++i)
template <typename Tx> inline void read(Tx &x) {x = 0; bool f = 0; char ch = getchar(); while (ch < '0' || ch > '9') f ^= ch == '-', ch = getchar(); while (ch <= '9' && ch >= '0') x = x * 10 + ch - '0', ch = getchar(); if (f) x = -x;}
template <typename Tx, typename ...Ty> inline void read(Tx &x, Ty &...y) {read(x), read(y...);}
#define File(filename) freopen(filename".in", "r", stdin), freopen(filename".out", "w", stdout)
const int mod = 998244353;
const int N = 509;
const int V = 500;
int n, m;
int lx[N], rx[N], ly[N], ry[N];
int _f[N][N][N * 2], *f[N][N];
void add(int &a, int b) {
a += b;
if (a >= mod) a -= mod;
}
void skymaths() {
read(n, m);
rep (i, 1, n) read(lx[i], rx[i]);
rep (i, 1, m) read(ly[i], ry[i]);
for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) f[i][j] = _f[i][j] + N;
f[0][0][0] = 1; f[0][0][1] = -1;
rep (i, 0, n) {
rep (j, 0, m) {
rep (v, -V, V) {
add(f[i][j][v], f[i][j][v - 1]);
// sumx - sumy = v
if (f[i][j][v]) {
if (v >= 0) {
if (j < m) {
add(f[i][j + 1][v - ry[j + 1]], f[i][j][v]);
add(f[i][j + 1][v - ly[j + 1] + 1], -f[i][j][v]);
// rep (y, ly[j + 1], ry[j + 1]) {
// add(f[i][j + 1][v - y], f[i][j][v]);
// }
}
}
else {
if (i < n) {
add(f[i + 1][j][v + lx[i + 1]], f[i][j][v]);
add(f[i + 1][j][v + rx[i + 1] + 1], -f[i][j][v]);
// rep (x, lx[i + 1], rx[i + 1]) {
// add(f[i + 1][j][v + x], f[i][j][v]);
// }
}
}
}
}
}
}
rep (a, 1, n) {
rep (b, 1, m) {
printf("%d ", f[a][b][0]);
}
printf("\n");
}
}
signed main() {
double start_time = clock();
// File("a");
int T = 1;
// scanf("%d", &T);
while (T--) {
skymaths();
}
cerr << "Time:" << (clock() - start_time) / CLOCKS_PER_SEC << "s\n";
return 0;
}
}
signed main() {
Main::main();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 7068kb
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: 1075ms
memory: 1006092kb
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 79401 9145270 673005095 -607948105 -878075908 613167438 134197138 227422896 253244876 169918839 578006994 577428019 950264843 43580983 -1770831458 658092971 175010620 -383806544 -280878131 -1268728821 81654991 8593295 777174082 -795413014 676314653 -690046231 950893720 544580764 639730560 -81308...
result:
wrong answer 5th numbers differ - expected: '180581065', found: '-607948105'