AtCoder Regular Contest 197 (Div. 2)
翻译中…
Problem Statement
翻译中…
You are given an $N\times N$ matrix $A = (A_{i,j})$ ($1\le i,j\le N$) whose entries are $0$ or $1$.
翻译中…
Find, modulo $998244353$, the number of trees $G$ on $N$ vertices numbered $1$ to $N$ that satisfy the following condition.
翻译中…
$A_{i,j}=1$if and only if at least one of the following holds:- When
$G$is rooted at vertex$1$, Vertex$j$is an ancestor of vertex$i$. That is, vertex$j$lies on the unique path in$G$between vertices$1$and$i$.- When
$G$is rooted at vertex$1$, Vertex$i$is an ancestor of vertex$j$. That is, vertex$i$lies on the unique path in$G$between vertices$1$and$j$.
- When
翻译中…
Here, the endpoints of a path are considered to be on that path. Note that $G$ being a tree guarantees uniqueness of the path between any two vertices.
翻译中…
There are $T$ test cases; solve each one.
翻译中…
Constraints
翻译中…
$1\leq T\leq 10^5$$2\leq N\leq 400$$A_{i,j}\in \lbrace 0,1\rbrace$$(1\leq i,j\leq N)$$A_{i,i}=1$$(1\leq i\leq N)$$A_{i,j}=A_{j,i}$$(1\leq i,j\leq N)$- The sum of
$N^2$over all test cases is at most$400^2$.
翻译中…
Input
翻译中…
The input is given from Standard Input in the following format:
翻译中…
T
\text{case}_1
\vdots
\text{case}_T
翻译中…
Each case is given in the following format:
翻译中…
N
A_{1,1} \cdots A_{1,N}
\vdots
A_{N,1} \cdots A_{N,N}
翻译中…
Output
翻译中…
Print $T$ lines. The $i$-th line should contain the number, modulo $998244353$, of trees $G$ satisfying the conditions for the $i$-th test case.
翻译中…
样例
Input #1
5
3
1 1 1
1 1 0
1 0 1
3
1 1 1
1 1 1
1 1 1
3
1 0 0
0 1 0
0 0 1
3
1 0 1
0 1 1
1 1 1
7
1 1 1 1 1 1 1
1 1 0 1 0 1 1
1 0 1 1 1 1 0
1 1 1 1 1 1 1
1 0 1 1 1 1 0
1 1 1 1 1 1 1
1 1 0 1 0 1 1
Output #1
1
2
0
0
8
In the first test case, the following one tree $G$ satisfies the condition: 
In the second test case, the following two trees $G$ satisfy the condition: 
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。