#P12796. [NERC 2022] Game of Questions

    ID: 12576 Type: RemoteJudge 5000ms 1024MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>2022Special JudgeICPCNERC/NEERC

[NERC 2022] Game of Questions

题目描述

Genie is taking part in an intellectual game. The game consists of nn questions, and there are mm participants numbered from 11 to mm. Genie is the participant number 11.

For each question ii and participant jj, it is known whether the participant will answer the question correctly or not.

The goal of the game is to be the last participant staying in the game.

The game is conducted as follows. First, all nn questions get shuffled uniformly at random (all n!n! permutations are equally likely). Then, the questions are asked one by one. Each participant answers the question. If all participants still in the game answer the question correctly, or if all of them answer the question incorrectly, nothing happens. Otherwise, those participants who answer the question incorrectly lose and leave the game.

After all nn questions are asked, all participants who are still in the game are declared to be the winners.

What is the probability that Genie will win the game?

输入格式

The first line contains two integers nn and mm --- the number of questions and the number of participants (1n21051 \le n \le 2 \cdot 10^5; 2m172 \le m \le 17).

The ii-th of the next nn lines contains mm characters si,1,si,2,,si,ms_{i, 1}, s_{i, 2}, \ldots, s_{i, m}. Character si,js_{i, j} is 1\tt{1} if participant jj answers question ii correctly or 0\tt{0} otherwise.

输出格式

Print the probability that Genie will win the game. Your answer will be considered correct if its absolute or relative error does not exceed 10910^{-9}.

1 5
11010
1.0000000000000000
3 3
011
101
110
0.3333333333333333
6 4
1011
0110
1111
0110
0000
1101
0.1666666666666667

提示

In the first example, there is a single question and Genie will answer it correctly, thus winning the game (along with participants 22 and 44).

In the second example, one participant will leave after the first asked question, and another participant will leave after the second asked question. Each participant will win with probability 13\frac{1}{3}.