题解:P4853 yyf hates dagequ
UPD:修正了一些笔误。
思维难度不大,但是挺恶心的。
期望 DP,考虑设计状态。
状态第一维设成考虑到第
然后想一想我们还缺些什么。两个技能都和连击次数有关,第二维给当前连击了
因此,我们可以定义状态为:
发现卡片有很多,在 DP 的时候枚举会超时。发现加分卡使用的关键在于连击次数,改判卡使用的关键在于连击次数和持续时间,这几个是和状态相关的。因此我们考虑分别预处理。
对于加分卡的预处理,我们不妨设
对于改判卡的预处理,我们不妨设
当然我们不能把持续时间都为
我们可以这样做:将所有改判卡按
具体怎么做呢?我们考虑固定连击次数
最后是 DP 环节。设第
- 若断连,此时
f_{i,j,k} = f_{i+1,0,\max(k-1,0)} + a_i 。 - 若连击,考虑触发卡片,枚举触发卡片后新的
t ,此时f_{i,j,k} = 2 \times (j + 2) + g_{j + 1} + \sum_{t=0}^5 f_{i+1,j+1,\max(k-1,t)} \times P_{j+1,t} 。
答案为
:::success[CODE]
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 1024;
int n, o, oo;
int a[maxn];
double g[maxn], p[maxn][6], f[maxn][maxn][6];
struct V {
int x;
double y;
int z;
}b[maxn];
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> o >> oo;
for (int i = 1; i <= o; i++) {
int x, y, z;
cin >> x >> y >> z;
for (int j = x; j <= n; j += x) {
g[j] += y / 100.0 * z;
}
}
for (int i = 1; i <= oo; i++) {
int x, y, z;
cin >> x >> y >> z;
b[i] = {x, y / 100.0, z};
}
for (int i = 1; i <= n; i++) cin >> a[i];
p[0][0] = 1;
sort(b + 1, b + oo + 1, [](V x, V y){return x.z > y.z;});
for (int i = 1; i <= n; i++) p[i][0] = 1;
for (int o = 1; o <= oo; o++) {
V j = b[o];
for (int i = j.x; i <= n; i += j.x) {
p[i][j.z] += p[i][0] * j.y;
p[i][0] *= 1 - j.y;
}
}
for (int i = n; i; i--) {
for (int j = 0; j < i; j++) {
for (int k = 0; k <= 5; k++) {
if (a[i] == 0 || (a[i] == 1 && !k)) f[i][j][k] += f[i + 1][0][max(k - 1, 0ll)] + a[i];
else {
for (int t = 0; t <= 5; t++) f[i][j][k] += p[j + 1][t] * (f[i + 1][j + 1][max(k - 1, t)]);
f[i][j][k] += 2 * (j + 2) + g[j + 1];
}
}
}
}
cout << fixed << setprecision(8) << f[1][0][0];
return 0;
}
/*
There is no end though there is a start in space. ---Infinity.
It has own power, it ruins, and it goes though there is a start also in the star. ---Finite.
Only the person who was wisdom can read the most foolish one from the history.
The fish that lives in the sea doesn't know the world in the land.
It also ruins and goes if they have wisdom.
It is funnier that man exceeds the speed of light than fish start living in the land.
It can be said that this is an final ultimatum from the god to the people who can fight.
*/
:::
欢迎找错,欢迎 hack。