QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#577894 | #9220. Bus Analysis | Yansuan_HCl | WA | 399ms | 9616kb | C++20 | 2.1kb | 2024-09-20 15:19:22 | 2024-09-20 15:19:22 |
Judging History
answer
#include <bits/stdc++.h>
#define ms(x, v) memset(x, v, sizeof(x))
#define il __attribute__((always_inline)) static
#define U(i,l,r) for(int i(l),END##i(r);i<=END##i;++i)
#define D(i,r,l) for(int i(r),END##i(l);i>=END##i;--i)
using namespace std;
using ll = unsigned int;
#define IC isdigit(c)
#define GC c=getchar()
void rd(auto &x) { x = 0; char GC; bool f = 0;
for (; !IC; GC) f |= c == '-';
for (; IC; GC) x = x * 10 + c - 48;
if (f) x = -x;
}
void rd(auto &x, auto &...y) { rd(x); rd(y...); }
#define meow(...) fprintf(stderr, __VA_ARGS__)
#define Assert(e, v) if (!(e)) exit(v);
#define int ll
const int N = 1003;
int n, t[N];
// 使位置 i 合法的最小代价
// 维护 [i-75, i) 的 dp 值
// 每段的起点,三个 [i-75, z, y, x) i
// 代价为0:x+20 / y+40 / z+75 cover i
const int P = 998244353;
const int K = 76;
pair<int, int> f[K][K][K], g[K][K][K];
il void I(int &x, int v) { (x += v) >= P ? (x -= P) : 0; }
#define lim(u) min((u), 75u)
void migr(pair<int, int> &a, const pair<int, int> &b, int d) {
I(a.first, b.first); I(a.second, b.second);
if (d) I(a.first, b.second);
}
signed main() {
// freopen("ava.in", "r", stdin);
rd(n);
U (i, 1, n) rd(t[i]);
// f_i (x,y,z) : 某一段的第一个在 i-x。第0段是 (i-x,i],第一段是 (i-y,i-x]
f[1][1][1] = {0, 1};
U (i, 1, n) {
U (x, 1, min(i, 75u)) U (y, x, min(i, 75u)) U (z, y, min(i, 75u)) {
// 1. 第 i 位存在
// 1.1. 能 = f(i-1)
int u = i - 1 - x + 1, v = i - 1 - z + 1;
if ((u > 0 && t[u] + 20 > t[i]) || (v > 0 && t[v] + 75 > t[i])) {
migr(g[lim(x + 1)][lim(y + 1)][lim(z + 1)], f[x][y][z], 0);
} else {
migr(g[1][lim(x + 1)][lim(y + 1)], f[x][y][z], 1);
}
// 2. 第 i 位不存在
migr(g[lim(x + 1)][lim(y + 1)][lim(z + 1)], f[x][y][z], 0);
}
U (x, 1, min(i + 1, 75u)) U (y, x, min(i + 1, 75u)) U (z, y, min(i + 1, 75u)) {
f[x][y][z] = g[x][y][z];
g[x][y][z] = {0, 0};
}
}
int ans = 0, tot = 0;
U (x, 1, 75) U (y, x, 75) U (z, y, 75) {
I(ans, f[x][y][z].first);
I(tot, f[x][y][z].second);
}
clog << "#" << tot << endl;
printf("%d\n", ans * 2 %P);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5876kb
input:
3 1 8 20
output:
14
result:
ok 1 number(s): "14"
Test #2:
score: 0
Accepted
time: 1ms
memory: 5824kb
input:
5 25 45 65 85 1000000000
output:
156
result:
ok 1 number(s): "156"
Test #3:
score: -100
Wrong Answer
time: 399ms
memory: 9616kb
input:
1000 2 7 9 12 14 17 18 21 22 28 29 33 34 35 37 38 44 45 46 50 58 59 63 66 71 72 75 76 77 78 80 81 83 84 87 92 100 101 107 108 109 112 114 116 118 123 124 131 142 143 144 145 148 150 151 152 153 155 157 158 165 167 168 169 171 176 182 185 190 192 198 202 204 205 212 213 223 224 225 226 229 231 240 24...
output:
551503931
result:
wrong answer 1st numbers differ - expected: '932594593', found: '551503931'