#P2746. [IOI 1996 / USACO5.3] 校园网 Network of Schools

    ID: 1754 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>2001USACOIOI强连通分量,缩点Tarjan

[IOI 1996 / USACO5.3] 校园网 Network of Schools

Description

Some schools share software with other schools; that is, if a school obtains the software, then all schools in its sharing list will also obtain the software. Note that this relation is directed: if aa is in bb's list, then bb is not necessarily in aa's list.

Now you need to distribute new software to some of the schools. To minimize the distribution cost, answer the following two questions.

  1. What is the minimum number of schools to which you must distribute the software so that all schools obtain the new software?
  2. Define one expansion as adding one school to the sharing list of some school. What is the minimum number of expansions needed so that, no matter which single school you initially distribute the software to, all schools will obtain the new software?

The two questions are independent.

Input Format

The first line of input contains a positive integer NN, the number of schools. The schools are numbered from 11 to NN.

Each of the next NN lines describes a sharing list. Line i+1i+1 lists the school IDs in the sharing list of school ii. Each list is terminated by a 00; an empty list is represented by a single 00.

Output Format

Output two lines.

The first line should contain a positive integer, the answer to Question 1.

The second line should contain a non-negative integer, the answer to Question 2.

5
2 4 3 0
4 5 0
0
0
1 0
1
2

Hint

Constraints: 2N1002 \le N \le 100.

This translation is from NOCOW.

Translated by ChatGPT 5