#P9621. Expected Score in the Forced-Exit Music Game

    ID: 22768 Type: Default 1000ms 256MiB

Expected Score in the Forced-Exit Music Game

Expected Score in the Forced-Exit Music Game

In this problem, a musical performance is composed of (n) circles. A player starts at a randomly chosen position (i) (where (1 \le i \le n)) with equal probability and then clicks directly on circle (i) and subsequent circles one by one. For each circle (i), the judgement can be one of four outcomes: (\texttt{GREAT}), (\texttt{OK}), (\texttt{MEH}) and (\texttt{MISS}) with probabilities (P_{i,0}/100,\ P_{i,1}/100,\ P_{i,2}/100,\ P_{i,3}/100) respectively (with (P_{i,0}+P_{i,1}+P_{i,2}+P_{i,3}=100)). The score from a performance is computed as [ 300a + 100b + 50c, ] where (a, b, c, d) are the counts of (\texttt{GREAT}, \texttt{OK}, \texttt{MEH}) and (\texttt{MISS}) outcomes respectively. Note that (\texttt{MISS}) contributes no points.

A twist in the game is the forced exit mechanism: if the player obtains (K) consecutive (\texttt{MISS}) outcomes, the game immediately terminates. In such a case the score is calculated using all clicks from the starting circle until and including the (K)th consecutive (\texttt{MISS}).

Your task is to calculate the expected score of the performance. The overall expectation is computed by averaging over all possible starting positions. That is, if (f(i)) is the expected score when starting at circle (i), then the answer is [ \frac{1}{n} \sum_{i=1}^{n} f(i). ]

Note: In some test cases with large (n) data, a data generator is provided as an attachment (refer to the problem attachments for the generator functions).

inputFormat

The first line contains two integers (n) and (K) (the number of circles and the maximum allowed consecutive misses before forced exit). Each of the following (n) lines contains four integers (P_{i,0}, P_{i,1}, P_{i,2}, P_{i,3}) which represent the probabilities (in percent) for the outcomes (\texttt{GREAT}, \texttt{OK}, \texttt{MEH}, \texttt{MISS}) for the (i)th circle. It is guaranteed that (P_{i,0}+P_{i,1}+P_{i,2}+P_{i,3}=100) for every (i).

outputFormat

Output a single number representing the expected score. Answers within an absolute or relative error of 1e-6 will be accepted.

sample

3 2
100 0 0 0
0 50 0 50
0 0 100 0
183.3333333