作者:风暴工会 | 来源:互联网 | 2023-10-15 10:43
Description
click me
Solution
套路的状压期望DP题。。。
考虑倒退期望:设fi,j" role="presentation" >
fi,j
为一直到第i−1" role="presentation" >
i−1
轮、当前状态为j" role="presentation" >
j
的最大分数。
转移
若当前状态满足第k" role="presentation" >
k
个宝物的前提条件,那么选择取或不取。
若不满足,那么不取。
具体转移方程参看代码。
Source
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
typedef long long LL;
#define For(i, j, k) for (register int i = (j), i##_end_ = (k); i <= i##_end_; ++ i)
#define Fordown(i, j, k) for (register int i = (j), i##_end_ = (k); i >= i##_end_; -- i)
#define rep(i, k) for (register int i = 0, i##_end_ = (k); i
#define Set(a, b) memset(a, b, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define fir first
#define sec second
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) ((int)(a).size())
#define INF (0x3f3f3f3f)
#define INF1 (2139062143)
#define Mod (1000000007)
#define debug(...) fprintf(stderr, __VA_ARGS__)
template <typename T> inline bool chkmax(T &a, T b) { return a 1 : 0; }
template <typename T> inline bool chkmin(T &a, T b) { return b 1 : 0; }
inline int read() {
register int _ = 0, __ = 1; register char c_ = getchar();
for ( ; c_ <'0' || c_ > '9'; c_ = getchar()) if (c_ == '-') __ = -1;
for ( ; c_ >= '0' && c_ <= '9'; c_ = getchar()) _ = (_ <<1) + (_ <<3) + (c_ ^ 48);
return _ * __;
}
inline void File()
{
#ifdef hany01
freopen("bzoj1076.in", "r", stdin);
freopen("bzoj1076.out", "w", stdout);
#endif
}
const int maxn = 16, maxk = 101;
int K, n, p[maxn], pre[maxn], all, tmp;
double f[maxk][1 <int main()
{
File();
K = read(), n = read();
For(i, 1, n) {
p[i] = read();
while (tmp = read()) pre[i] |= (1 <<(tmp - 1));
}
all = (1 <