#P2473. [SCOI2008] 奖励关
[SCOI2008] 奖励关
Description
You are playing your favorite video game and have just entered a bonus stage. In this stage, the system will randomly drop items times in sequence. Each time, you may choose to take the item or not take it (you must decide before the next drop, and an item you skip now cannot be taken later).
There are types of items. Each drop is equally likely to be any of the types, and all drops are independent. That is, even if the system drops item in the first drops (which is possible, though very unlikely), the probabilities for the -th drop are still all .
Taking an item of type yields points, but not every item can be taken freely. Item has a prerequisite set . You can take item only if every item in has been taken at least once. If the system drops an item that you currently cannot take, that opportunity is simply lost. Note that can be negative; however, if it is a prerequisite for many high-scoring items, taking this negative item at a short-term loss may lead to greater long-term gain.
Assuming you follow the optimal strategy, what is the expected total score you can obtain in the bonus stage?
Input Format
The first line contains two integers, the number of drops and the number of item types .
Lines through describe the items. On line , several integers describe item : first an integer , then several distinct integers giving the prerequisites , and finally an integer marking the end of the line.
Output Format
Output a single real number, the answer, with six digits after the decimal point.
1 2
1 0
2 0
1.500000
6 6
12 2 3 4 5 0
15 5 0
-2 2 4 5 0
-11 2 5 0
5 0
1 2 4 5 0
10.023470
Hint
Constraints
For all test points, it is guaranteed that , , and .
Translated by ChatGPT 5
京公网安备 11011102002149号