QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#845646 | #9220. Bus Analysis | hhoppitree | WA | 1ms | 5988kb | C++23 | 1.3kb | 2025-01-06 17:44:39 | 2025-01-06 17:44:39 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1005, P = 998244353;
void add(int &x, int y) {
((x += y) >= P) && (x -= P);
}
int a[N], pw[N], f[2][105][105][105];
signed main() {
int n; scanf("%d", &n);
for (int i = pw[0] = 1; i <= n; ++i) scanf("%d", &a[i]), pw[i] = 2 * pw[i - 1] % P;
a[n + 1] = a[n] + 1;
int res = 0;
f[1][0][0][0] = 1;
for (int i = 1; i <= n; ++i) {
for (int j = 0; j <= 75; ++j) {
for (int k = j; k <= j + 20; ++k) {
for (int l = j; l <= j + 20 && l <= 75; ++l) {
int v = f[i & 1][j][k][l], D = a[i + 1] - a[i];
if (!v) continue;
f[i & 1][j][k][l] = 0;
add(f[(i & 1) ^ 1][max(j - D, 0)][max(k - D, 0)][max(l - D, 0)], v);
if (!j) {
res = (res + 1ll * v * pw[n - i]) % P;
add(f[(i & 1) ^ 1][min(max(20 - D, 0), max(k - D, 0))][min(max(20 - D, 0), max(l - D, 0))][max(75 - D, 0)], v);
} else {
add(f[(i & 1) ^ 1][max(j - D, 0)][max(k - D, 0)][max(l - D, 0)], v);
}
}
}
}
}
printf("%d\n", res * 2 % P);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5988kb
input:
3 1 8 20
output:
14
result:
ok 1 number(s): "14"
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 5944kb
input:
5 25 45 65 85 1000000000
output:
64
result:
wrong answer 1st numbers differ - expected: '156', found: '64'