## IOI '96 P3 - Network of Schools

View as PDF

Points: 12 (partial)
Time limit: 1.0s
Memory limit: 32M

Problem type
##### IOI '96 - Veszprém, Hungary

A number of schools are connected to a computer network. Agreements have been developed among those schools: each school maintains a list of schools to which it distributes software (the "receiving schools"). Note that if is in the distribution list of school , then does not necessarily appear in the list of school .

You are to write a program that computes the minimal number of schools that must receive a copy of the new software in order for the software to reach all schools in the network according to the agreement (Subtask ). As a further task, we want to ensure that by sending the copy of new software to an arbitrary school, this software will reach all schools in the network. To achieve this goal we may have to extend the lists of receivers by new members. Compute the minimal number of extensions that have to be made so that whatever school we send the new software to, it will reach all other schools (Subtask ). One extension means introducing one new member into the list of receivers of one school.

#### Input Specification

The first line of the input file contains an integer : the number of schools in the network . The schools are identified by the first positive integers. Each of the next lines describes a list of receivers. The line contains the identifiers of the receivers of school . Each list ends with a . An empty list contains a alone in the line.

#### Output Specification

Your program should write two lines to the output file. The first line should contain one positive integer: the solution of subtask . The second line should contain the solution of subtask .

#### Sample Input

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

#### Sample Output

1
2