luogu#P4853. yyf hates dagequ
yyf hates dagequ
Background
The unlucky player yyf, guided by dew, drew some pretty good cards, but he is still too unlucky. For randomly triggered skills, he always fails to trigger them. yyf wants to know how unlucky he really is, so he asks you to compute his expected score and compare it with his actual score.
The precision limit for this problem has been relaxed, and both Wrong Answer and Correct Answer are shown. Please do not design solutions based on this.
Problem Description
You are given some card skills. There are types of skills:
- Bonus score: every time you reach a combo of , there is a chance to gain points.
- Judgment change: every time you reach a combo of , there is a chance to trigger a “strong judgment effect”, lasting for rhythm icons (suppose that when the combo count is a multiple of , it corresponds to the -th rhythm icon; then the strong judgment effect is applied on the rhythm icons).
These skills have a chance to trigger when the combo count is a multiple of and the combo count is not . Multiple skills may trigger at the same time.
Among them, there are bonus-score skills and judgment-change skills.
You are also given rhythm icons (yyf hits them in the given order). yyf’s original (relative to the result after applying the “strong judgment effect”) hit result for each icon is one of , , or .
During the duration of a “strong judgment effect”, all hit results are treated as hit results . Hit result is still treated as , and hit result is still treated as . Unless otherwise stated, “hit result” below refers to the corrected hit result.
The definition of “combo count” is the number of consecutive hit results equal to so far (if the current hit result is , then this hit is also counted into the current combo; otherwise, the current combo becomes ).
Multiple “strong judgment effects” can overlap, but their durations do not stack. (Let the remaining time of the current “strong judgment effect” be . If two “strong judgment effects” are triggered simultaneously now, with durations and , then at the next hit, the remaining time becomes .)
The score of one hit equals the hit result multiplied by the current combo plus one. That is, let the current hit result be and the current combo be , then the score of this hit is .
The final score is the sum of the scores of all hits (a total of hits) plus the total bonus points gained from bonus-score skills.
Please compute the expected final score for yyf in this song.
Input Format
The first line contains three non-negative integers .
The next lines each contain three positive integers , describing a bonus-score skill.
The next lines each contain three positive integers , describing a judgment-change skill.
The last line contains integers, each in . The -th integer represents the original result of the -th hit.
Output Format
Output one real number in a single line, representing yyf’s expected score. Your answer is accepted if the relative error is within .
4 1 1
3 70 3
2 20 1
2 2 1 1
13.82
5 0 2
2 60 1
2 10 2
2 2 1 1 1
19.084
5 0 0
2 1 0 2 2
15
Hint
Constraints
For all test points: , , , , , , .
| Test Point ID | Special Constraint | Test Point ID | Special Constraint | ||||||
|---|---|---|---|---|---|---|---|---|---|
| All are | None | ||||||||
| None | |||||||||
| All are | |||||||||
| None | |||||||||
Sample 1 Explanation

Sample 2 Explanation

Sample 3 Explanation
The first hit scores points, the second hit scores point, the third hit scores points, the fourth hit scores points, and the fifth hit scores points.
Translated by ChatGPT 5