USACO Network of Schools(学校网络) —强连通分量

描述

一些学校的校园网连接在一个计算机网络上。学校之间存在软件支援协议。每个学校都有它应支援的学校名单(学校a支援学校b,并不表示学校b一定支援学校a)。当某校获得一个新软件时,无论是直接得到的还是从网络得到的,该校都应立即将这个软件通过网络传送给它应支援的学校。因此,若需要让所有连接在网络上的学校都能使用一个新软件,只需要将其提供给其中一些学校即可。

子任务a:根据学校间软件支援协议(各个学校的支援名单),计算最少需要将一个软件直接提供给多少个学校,才能使该软件通过网络传送到所有学校。

子任务b:如果允许在原有支援协议上添加新的支援关系,则总可以形成一个新的协议,使得此时只需要将一个新软件提供给任何一个学校,其他所有学校就都可以通过网络获得该软件。请计算出最少需要添加几条新的支援关系。

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 B is in the distribution list of school A, then A does not necessarily appear in the list of school B
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 A).
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 B).
One extension means introducing one new member into the list of receivers of one school.

格式

输入格式

第一行是一个整数 n(2≤n≤100),表示与网络连接的学校总数。接下来 n行描述了每个学校要支援的学校。第i+1行表示第i 号学校要支援的所有学校的编号,编号之间用空格隔开,每行以数字0 结束。如果某个学校不支援任何学校,则相应的行会有一个0。

The first line contains an integer N: the number of schools in the network (2

输出格式

包含两行,第一行是一个正整数,表示子任务a的解。第二行也是一个正整数,表示子任务b的解。

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

样例1

样例输入1

Copy

样例输出1

Copy

提示

图结构

来源

安徽省芜湖市二十七中练习题

IOI 1996 Network of Schools(NET)

Description:Official(English)/Unknown(Chinese Simplified)
Data:Official
Program:JackDavid127

 

USACO Network of Schools(学校网络) ---强连通分量 USACO Network of Schools(学校网络) ---强连通分量 代码

 

来源:WhiStLenA

声明:本站部分文章及图片转载于互联网,内容版权归原作者所有,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2017年9月13日
下一篇 2017年9月13日

相关推荐