QOJ.ac

QOJ

Time Limit: 5 s Memory Limit: 1024 MB Total points: 100

#5205. 问题游戏

Statistics

Genie 正在参加一场智力竞赛。比赛包含 $n$ 个问题,共有 $m$ 名参赛者,编号为 $1$ 到 $m$。Genie 是 1 号参赛者。

对于每个问题 $i$ 和参赛者 $j$,已知该参赛者是否能正确回答该问题。

比赛的目标是成为最后留在游戏中的参赛者。

比赛流程如下:首先,所有 $n$ 个问题会被均匀随机地打乱(所有 $n!$ 种排列的可能性均等)。然后,问题会被逐一提出。每位参赛者都会回答问题。如果所有仍在游戏中的参赛者都正确回答了该问题,或者所有仍在游戏中的参赛者都错误回答了该问题,则什么都不会发生。否则,那些回答错误的人将被淘汰并离开游戏。

在所有 $n$ 个问题提出后,所有仍在游戏中的参赛者即为获胜者。

求 Genie 赢得比赛的概率。

输入格式

第一行包含两个整数 $n$ 和 $m$ —— 问题的数量和参赛者的数量($1 \le n \le 2 \cdot 10^5$;$2 \le m \le 17$)。

接下来的 $n$ 行中,第 $i$ 行包含 $m$ 个字符 $s_{i,1}, s_{i,2}, \dots, s_{i,m}$。如果参赛者 $j$ 能正确回答问题 $i$,则字符 $s_{i,j}$ 为 '1',否则为 '0'。

输出格式

输出 Genie 赢得比赛的概率。如果你的答案的绝对误差或相对误差不超过 $10^{-9}$,则被视为正确。

样例

输入 1

1 5
11010

输出 1

1.0000000000000000

输入 2

3 3
011
101
110

输出 2

0.3333333333333333

输入 3

6 4
1011
0110
1111
0110
0000
1101

输出 3

0.1666666666666667

说明

在第一个样例中,只有一个问题,且 Genie 会正确回答它,因此赢得了比赛(与参赛者 2 和 4 一起)。

在第二个样例中,一名参赛者会在第一个问题提出后离开,另一名参赛者会在第二个问题提出后离开。每位参赛者获胜的概率均为 $\frac{1}{3}$。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.