#P4853. Expected Score in Rhythm Game with Card Skills

    ID: 18095 Type: Default 1000ms 256MiB

Expected Score in Rhythm Game with Card Skills

Expected Score in Rhythm Game with Card Skills

You are given a rhythm game where a player uses card skills during a song. There are two types of card skills:

  • Score Boost Skill: Every time the player's combo (i.e. the number of consecutive beats with a "2" result) becomes a positive multiple of \(c\) (i.e. when the combo reaches \(c, 2c, 3c, \dots\)), each of these skills triggers with a probability of \(p\%\) and adds \(s\) points.
  • Judge Modification Skill: Under the same condition (combo is a positive multiple of \(c\)), each such skill triggers with a probability of \(p\%\) and activates an Enhanced Judge Effect for the next \(t\) beat icons. If the current beat (when the effect is triggered) is considered the \(i\)th beat icon among those beats where the combo reaches a multiple of \(c\), then the effect applies to beats \(i+1, i+2, \dots, i+t\).

Notes about the game mechanics:

  • There are score number of Score Boost skills and judge number of Judge Modification skills.
  • The skills may trigger simultaneously. They only have a chance to trigger when the current combo (number of consecutive beats with result \(2\)) is a positive multiple of \(c\).
  • The player is given \(n\) beat icons. For each beat, an initial (or raw) hit result is provided: either 2, 1, or 0.
  • During an active Enhanced Judge Effect (which lasts for a number of beats), any hit with a raw result of 1 is upgraded to 2. A hit with a raw result of 0 or 2 remains unchanged. In the following, hit result always means the modified result.
  • Multiple Enhanced Judge Effects can overlap; however, their durations do not stack. Specifically, if the current effect has a remaining duration of \(r_1\) (in beats) and at a beat two new effects are triggered (with durations \(t_2\) and \(t_3\) respectively), then the remaining duration for the next beat becomes \(\max(r_1-1, t_2, t_3)\).
  • The combo is defined as the number of consecutive beats (up to the current beat) that have a hit result of 2 (note that if the current beat is a 2, it is counted in the combo; otherwise, the combo resets to 0).
  • Each beat's score is calculated as follows: if the effective hit result is \(x\) and the current combo (including the hit if it is a \(2\)) is \(\text{combo}\), then the score for that beat is \(x \times (\text{combo}+1)\). (For non-\(2\) hits, the combo is 0 and the score is simply \(x\)).
  • The final total score is the sum of the scores of all beats plus all bonus points from the Score Boost skills.

Your task is to compute the expected final score of the player, given the randomness of the skill triggers. All probability parameters are given as percentages, and when a skill triggers the probability is independent for each skill. In particular, when a beat qualifies for triggering (i.e. when the new combo is a positive multiple of \(c\)):

  • Each Score Boost skill adds an additional \(s\) points with probability \(p\%\) (so the total expected bonus from score skills is \(\mathrm{score} \times \frac{p}{100} \times s\)).
  • Each Judge Modification skill triggers independently with probability \(p\%\). Let \(P_j = 1 - (1-\frac{p}{100})^{\mathrm{judge}}\) be the probability that at least one Judge Modification skill triggers, which then applies an effect that lasts for \(t\) beats.

Input/Output summary:

inputFormat

The input consists of two lines:

  1. The first line contains seven integers separated by spaces: n c p s t score judge where
    • \(n\): number of beats,
    • \(c\): combo multiple required for a skill trigger,
    • \(p\): probability percentage for each skill trigger,
    • \(s\): points added by one Score Boost skill when triggered,
    • \(t\): duration (in beats) of the Enhanced Judge Effect when triggered,
    • score: number of Score Boost skills,
    • judge: number of Judge Modification skills.
  2. The second line contains \(n\) integers separated by spaces, each being 0, 1, or 2, representing the raw hit results in order.

outputFormat

Output a single floating-point number representing the expected final score. The answer will be accepted if it is correct within an absolute or relative error of \(10^{-6}\).

sample

5 2 50 10 2 1 1
2 1 2 1 0
Expected output (floating-point value)