#P7105. 「C.E.L.U-01」门禁

「C.E.L.U-01」门禁

Background

Once, abruce went to the computer lab quite early, and then... he waited outside for 35 minutes... So he thought of this question:
The door of the computer lab is locked. There are nn students who all need to get in, and to enter they must have an access card. However, some students may go together. For a group that goes together, as long as at least one person brings an access card, they will not be awkwardly locked outside. Now the teacher is finally going to hand out access cards, but how many cards should be given out?

Problem Description

We simplify the problem in the background. You are given nn points, and for any two points i,ji,j, there is an undirected edge between them with probability pi,jp_{i,j}. Find the expected number of connected components in the graph.

Input Format

The first line contains an integer nn.
Lines 22 to n+1n+1 each contain nn real numbers, representing pi,jp_{i,j}. The testdata guarantees that for any 1in1\le i \le n, pi,i=0p_{i,i}=0; for any 1i,jn1\le i,j \le n, pi,j=pj,ip_{i,j}=p_{j,i}; 0pi,j10\le p_{i,j}\le1. The input real numbers have at most 33 digits after the decimal point.

Output Format

Output one real number in a single line, representing the expected number of connected components. Your answer is considered correct if the absolute error from the standard answer does not exceed 10410^{-4}.

3
0 0.5 0.5
0.5 0 0.5
0.5 0.5 0
1.625000
4
0 0.129 0.58 0.37
0.129 0 0.22 0.134
0.58 0.22 0 0.6
0.37 0.134 0.6 0
2.143266

Hint

Sample Explanation 1: The following eight cases each occur with probability 18\dfrac{1}{8}.

The numbers of connected components are 3,2,2,2,1,1,1,13,2,2,2,1,1,1,1.
So the expectation is $\dfrac{1}{8}\times3+\dfrac{3}{8}\times2+\dfrac{4}{8}\times1=\dfrac{13}{8}=1.625$

Constraints:

Test ID nn Special Property
131\sim3 4\le4 None
44 8\le8 pi,j=0p_{i,j}=0 or pi,j=1p_{i,j}=1
565\sim6 When iji\not=j, pi,j=0.5p_{i,j}=0.5
787\sim8 None
9109\sim10 11\le11
111211\sim12 14\le14

Translated by ChatGPT 5