#7462. [SWERC 2024] Divination
[SWERC 2024] Divination
[SWERC 2024] Divination
题目描述
In Yinxu, the archaeological site of the late capital of the Shang Dynasty, there are $N$ divination papers written in oracle bone script, numbered $1, 2, ..., N$. Some papers may cite other papers, but no paper can cite itself. Additionally, there are no circular citations, meaning it's not possible to see the following situation: $A_1$ cites $A_2$, $A_2$ cites $A_3$, ..., $A_{K-1}$ cites $A_K$, $A_K$ cites $A_1$ (where $2 \leq K \leq N$).As per myth, a complete set of divination papers can predict the wars and peace of the next century, and it should have a complete citation chain, i.e., cites , cites , ..., cites , without any papers missing. Please determine whether these divination papers constitute a complete set.
输入格式
The first line contains an integer $N$, represents the number of papers. Then $N$ lines follow, the $i^{th}$ of them represents the citations of the $i^{th}$ paper: the first integer $c_i$ represents the number of its citations, followed by $c_i$ integers $p_{i,1}, p_{i,2}, ..., p_{i,c_i}$ that represent the papers that it cites.输出格式
A single integer, $1$ if they constitute a complete set of divination papers, or $0$ otherwise.4
0
2 1 4
2 2 4
1 1
1
4
0
1 1
2 2 4
1 1
0
提示
### Sample Explanation 1In this sample, paper cites paper , paper cites paper , paper cites paper . Thus, we find a complete citation chain, which makes them a complete set of divination papers.
Limits
- ;
- for all ;
- ;
- for all and .
- for all and . 标签: P15155|图论|2024|拓扑排序|ICPC