#P15841. [Bulgarian NOI 2024] 公平 / Fair
[Bulgarian NOI 2024] 公平 / Fair
Problem Description
Felicia Day likes playing DnD. For this, she needs various -sided dice. But she is a bit short on money, so to save some, she bought dice during a sale. However, she found that not all dice are fair (a die is fair if and only if each face has the same probability of appearing). More precisely, each die is fair with probability ; if it is unfair, then the probability of each face is generated as follows:
- For from to , generate a random number between and , denoted as .
- The probability that face appears equals .
We can view a fair die as a die where all values are equal.
Felicia is eager to determine which dice are fair and which are not, but time is limited, so she rolled each die times. She recorded the results, that is, how many times each face appeared for each die, but she is not sure how to analyze this data. Please write a program to help her classify the dice as “fair” or “unfair”. Of course, 100% correctness is not required. Instead, each mistake will be penalized: if you classify a fair die as unfair, the penalty is ; if you classify an unfair die as fair, the penalty is . Your goal is to minimize the total penalty.
Input Format
Read , , , , and from the first line of standard input. The next line contains . In the following lines, each line contains integers: the -th number on the -th line indicates the number of times face appeared on the -th die.
Output Format
For each die, output on a separate line in standard output 1 if you classify it as a fair die, or 0 if you classify it as an unfair die.
3 15 0.6 0.35 0.65
4
4 7 4
5 5 5
9 5 1
3 6 6
0
1
0
1
Hint
Sample 1 Explanation
It turns out that this solution classifies dice and correctly, but misclassifies dice and . The penalty from the first mistake is , and the penalty from the second mistake is . The total penalty is .
Constraints
Scoring
Each test point is scored independently. The score for a given test point is computed as follows:
- Let be the total penalty value of the mistakes made by your solution.
- $S = \max\left(\frac{\text{BAP} - \text{AP}}{\text{BAP}},\ 0\right)$
- Your score is:$$\begin{cases} 0.3 + 0.7 \times \left(1 - \left(1 - \frac{R - 0.8}{1 - 0.8}\right)^{0.75}\right) & \text{if } R \ge 0.8 \\ \frac{0.3}{0.8} \times R & \text{if } R < 0.8 \end{cases}$$
Translated by ChatGPT 5