#P2812. 校园网络【[USACO] Network of Schools加强版】

校园网络【[USACO] Network of Schools加强版】

Description

There are nn schools (1n100001 \leq n \leq 10000). It is known that in their designed network there are mm edges. To ensure high speed, the network is directed. Please tell them the minimum number of schools to select as servers (“mother machines”) so that every school can use the software. Then tell them the minimum number of edges to add so that choosing any single school as the server will allow every other school to use the software.

Input Format

The first line contains a positive integer nn.

The next nn lines each contain several integers separated by spaces.

On the (i+1)(i+1)-th line, several non-zero integers xx are given, indicating that there is a directed edge from ii to xx. The line ends with a terminating 00.

Output Format

The first line contains an integer, the minimum number of schools to select as servers so that every school can use the software.

The second line contains an integer, the minimum number of edges to add so that choosing any school as the server will allow every other school to use the software.

5
2 0
4 0
5 0
1 0
0

2
2

Hint

POJ original. The testdata has been enlarged by 100100 times.

1n100001 \leq n \leq 10000, 1m50000001 \leq m \leq 5000000.

In fact, 1n100001 \leq n \leq 10000, 1m500001 \leq m \leq 50000.

Translated by ChatGPT 5