题目描述
Problem Background
Unlucky yyf managed to draw some decent cards under dew's guidance, but he's still too unlucky. He can't trigger skills that activate randomly. yyf wants to know how unlucky he is, so he asks you to calculate his expected score to compare with his actual score.
This problem has relaxed precision constraints and displays incorrect and correct answers. Do not approach it based on the data.
Problem Description
You are given skills for some cards, which are divided into two types:
1. Score addition: There is a $p\%$ chance to add $s$ points for every $c$ consecutive hits.
2. Judgment modification: There is a $p\%$ chance to trigger a strong judgment effect for $t$ rhythm icons, starting from the next icon after every $c$ consecutive hits.
These skills have a chance to trigger when the consecutive hit count is a multiple of $c$ and not zero. Multiple skills can trigger simultaneously.
There are $\mathrm{score}$ score addition skills and $\mathrm{judge}$ judgment modification skills.
You are also given $n$ rhythm icons (yyf hits them in the given order) and the original (unmodified by "strong judgment effect") results of yyf's hits, which are either $2$, $1$, or $0$.
During the "strong judgment effect," all hit results of $1$ are treated as $2$, and hit results of $0$ remain as $0$. Hit results of $2$ remain as $2$. The term "hit result" refers to the modified result unless specified otherwise.
The "consecutive hit count" is defined as the number of consecutive hits with result $2$ so far (if the current hit result is $2$, it counts towards the current consecutive hit count; otherwise, the consecutive hit count resets to $0$).
Multiple "strong judgment effects" can overlap, but their durations do not stack. If the current remaining time of a "strong judgment effect" is $t_1$ and two "strong judgment effects" with durations $t_2$ and $t_3$ trigger simultaneously, the remaining time for the next hit will be $\max(t_1-1, t_2, t_3)$.
The score for a hit is the hit result multiplied by the current consecutive hit count plus one. That is, if the current hit result is $x$ and the current consecutive hit count is $\mathrm{combo}$, the score for this hit is $\mathrm{x*(combo+1)}$.
The final score is the sum of the scores for all $n$ hits plus the sum of points added by score addition skills.
Calculate yyf's expected score for this performance.
Input Format
The first line contains three non-negative integers $\mathrm{n\ score\ judge}$.
The next $\mathrm{score}$ lines each contain three positive integers $c\ p\ s$, representing a score addition skill.
The next $\mathrm{judge}$ lines each contain three positive integers $c\ p\ t$, representing a judgment modification skill.
The last line contains $n$ integers, each in the range $[0, 2]$, representing the original results of the $n$ hits.
Output Format
Output a single real number representing yyf's expected score, with a relative error of no more than $10^{-5}$.
Sample Input and Output
Input Sample #1
4 1 1
3 70 3
2 20 1
2 2 1 1
Output Sample #1
13.82
Input Sample #2
5 0 2
2 60 1
2 10 2
2 2 1 1 1
Output Sample #2
19.084
Input Sample #3
5 0 0
2 1 0 2 2
Output Sample #3
15
Notes/Hints
Data Range
For all test cases: $5 \le n \le 1000$, $0 \le \mathrm{score} \le 1000$, $0 \le \mathrm{judge} \le 1000$, $1 \le c \le 5$, $1 \le p \le 99$, $1 \le s \le 10$, $1 \le t \le 5$.
| Test Case Number | $n$ | $\mathrm{score}$ | $\mathrm{judge}$ | Special Constraints | Test Case Number | $n$ | $\mathrm{score}$ | $\mathrm{judge}$ | Special Constraints |
|---|---|---|---|---|---|---|---|---|---|
| $1$ | $1000$ | $\ \,0\ \,$ | $\ \,0\ \,$ | All $a_i$ are $2$ | $11$ | $1000$ | $\ \,0\ \,$ | $\ \,9\ \,$ | None |
| $2$ | $1000$ | $0$ | $0$ | None | $12$ | $1000$ | $2$ | $2$ | None |
| $3$ | $1000$ | $1$ | $0$ | None | $13$ | $1000$ | $3$ | $3$ | None |
| $4$ | $1000$ | $9$ | $0$ | None | $14$ | $1000$ | $3$ | $6$ | None |
| $5$ | $1000$ | $1000$ | $0$ | None | $15$ | $1000$ | $1$ | $8$ | All $c$ are $1$ |
| $6$ | $50$ | $1$ | $1$ | None | $16$ | $1000$ | $0$ | $9$ | All $c$ are $1$ |
| $7$ | $50$ | $2$ | $2$ | None | $17$ | $1000$ | $1000$ | $1000$ | All $c$ are $1$ |
| $8$ | $50$ | $4$ | $4$ | None | $18$ | $1000$ | $1000$ | $1000$ | All $c$ are $1$ |
| $9$ | $50$ | $0$ | $9$ | None | $19$ | $1000$ | $1000$ | $1000$ | None |
| $10$ | $50$ | $4$ | $5$ | None | $20$ | $1000$ | $1000$ | $1000$ | None |
Sample 1 Explanation
[Image explanation omitted]
Sample 2 Explanation
[Image explanation omitted]
Sample 3 Explanation
First hit: 4 points, second hit: 1 point, third hit: 0 points, fourth hit: 4 points, fifth hit: 6 points.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分