AtCoder Grand Contest 049
翻译中…
Problem Statement
翻译中…
We have a directed graph with $N$ vertices numbered $1$ to $N$. $N$ strings of length $N$ each, $S_1,S_2,\ldots,S_N$, represent the edges in the graph. Specifically, $S_{i,j}$ is 1 if there is an edge from Vertex $i$ to Vertex $j$, and 0 otherwise. The graph has no self-loops and no multi-edges.
翻译中…
Until the graph becomes empty, AtCobear will repeat the following operation:
翻译中…
- Choose one (unerased) vertex uniformly at random (independently from the previous choices). Then, erase that vertex and all vertices that are reachable from the chosen vertex by traversing some edges. Erasing a vertex will also erase the edges incident to it.
翻译中…
Find the expected value of the number of times the operation is done.
翻译中…
Constraints
翻译中…
$1 \leq N \leq 100$$S_i$is a string of length$N$consisting of0and1.$S_{i,i}=$0
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
N
S_1
S_2
\vdots
S_N
翻译中…
Output
翻译中…
Print the expected value of the number of times the operation is done. Your output will be considered correct when its absolute or relative error from our answer is at most $10^{-9}$.
翻译中…
样例
Input #1
3
010
001
010
Output #1
1.66666666666666666667
We have the following three scenarios happening with equal probability:
- Choose Vertex $1$ in the first operation, erasing Vertex $1$, $2$, and $3$. The graph is now empty, so we are done.
- Choose Vertex $2$ in the first operation, erasing Vertex $2$ and $3$. Then, choose Vertex $1$ in the second operation, erasing Vertex $1$. The graph is now empty, so we are done.
- Choose Vertex $3$ in the first operation, erasing Vertex $2$ and $3$. Then, choose Vertex $1$ in the second operation, erasing Vertex $1$. The graph is now empty, so we are done.
Thus, the expected value of the number of times the operation is done is $(1+2+2)/3=5/3$.
Input #2
3
000
000
000
Output #2
3.00000000000000000000
There will always be three operations.
Input #3
3
011
101
110
Output #3
1.00000000000000000000
There will always be one operation.
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。