Expected pressure DP ....
------------------------------------------------------------------
#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>#include <iostream>#define CLR (x, C) memset (x, C, sizeof (x))#define REP (i, n) for (int i = 0; i < n; ++i)#define B (i) (1 << (i))using namespace std;const int MAXN = MAXK =;int w[MAXN], s[MAXN];double d[maxk [B (MAXN)];int main () {freopen ("test.in", "R", stdin);int k, n;CLR (d, 0);Cin >> k >> N;Rep (i, N) {scanf ("%d", w + i);s[I] = 0;int t;scanf ("%d", &t);While (t) {s[i] |= b (t-1);scanf ("%d", &t);}}for (int i = k-1; I >= 0; i--)Rep (S, B (n)) {Rep (j, N)if ((s[j] & s) = = s[J])d[I [S] + = max (d[i + 1 [s | b (j)] + w[j], d[i + 1 [s]);Elsed[I [s] + = d[i + 1 [s];d[I [S]/= N; }printf ("%.6lf\n", d[0] [0]);return 0;}
------------------------------------------------------------------
1076: [SCOI2008] reward off time limit: Sec Memory Limit: 162 MB
Submit: 1094 Solved: 636
[Submit] [Status] [Discuss] Description
You are playing your favorite video game and have just entered a reward off. In this reward Sekiri, the system will randomly throw the K-times treasure, each time you can choose to eat or not to eat (must be before the next treasure to make a choice, and now decide not to eat the treasure will not eat again). There are a total of n species, the system each time the probability of throwing the N-type treasures are the same and independent of each other. That is, even if the former k-1 system throws the Treasure 1 (which is likely to occur, although the probability is very small), the probability of the K-throw of each treasure is still 1/n. I will get pi points for the first treasures, but not every treasure is freely available. The first treasures have a prerequisite for the collection of Si. Only if all the treasures in Si have been eaten at least once, can I have a treasure (if the system throws a treasure that is not currently edible, it is equivalent to losing one chance in vain). Note that pi can be negative, but if it is a precondition for many high-score treasures, losing short-term benefits and eating this negative-score treasure will gain greater long-term benefits. Assuming you take the optimal strategy, how many points can you get on average in the reward?
Input
The first behavior is two positive integers k and n, that is, the number and type of treasures. The following n lines describe a treasure, where the first integer represents the score, followed by an integer that in turn represents the individual premise treasures of the treasure (each treasure number is 1 to n), ending with 0.
Output
Outputs a real number, preserving six decimal places, which is the average score for the optimal strategy.
Sample Input1 2
1 0
2 0Sample Output1.500000HINT
"Data Size"
1<=k<=100,1<=n<=15, the score is an integer within [ -10^6,10^6].
Source
1076: [SCOI2008] reward off (DP)