POJ 1236 Network of Schools (Tarjan + 缩点)
2015-04-17 15:31
591 查看
Network of Schools
DescriptionA 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.
InputThe first line contains an integer N: the number of schools in the network (2 <= N <= 100). The schools are identified by the first N positive integers. Each of the next N lines describes a list of receivers. The line i+1 contains the identifiers of the receivers of school i. Each list ends with a 0. An empty list contains a 0 alone in the line.
OutputYour 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.
Sample Input
Sample Output
题意:软件发送为有向的,每个学校可以发给list中的其他学校,求:1.至少发多少个软件才能让所有学校都收到(A)2.在学校的关系之间加几条边可以让软件发给任意一个学校,其它都可以收到(B)思路:找图的强连通分量,则A=出度为0的强连通分量个数,B=入度为0的个数和初度为0的个数中较大的一个找强连通分量:Tarjan算法
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 12240 | Accepted: 4871 |
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.
InputThe first line contains an integer N: the number of schools in the network (2 <= N <= 100). The schools are identified by the first N positive integers. Each of the next N lines describes a list of receivers. The line i+1 contains the identifiers of the receivers of school i. Each list ends with a 0. An empty list contains a 0 alone in the line.
OutputYour 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.
Sample Input
5 2 4 3 0 4 5 0 0 0 1 0
Sample Output
1 2
题意:软件发送为有向的,每个学校可以发给list中的其他学校,求:1.至少发多少个软件才能让所有学校都收到(A)2.在学校的关系之间加几条边可以让软件发给任意一个学校,其它都可以收到(B)思路:找图的强连通分量,则A=出度为0的强连通分量个数,B=入度为0的个数和初度为0的个数中较大的一个找强连通分量:Tarjan算法
相关文章推荐
- POJ 1236 Network of Schools(强连通分量/Tarjan缩点)
- Network of Schools POJ - 1236 tarjan强连通分量缩点
- POJ 1236 Network of Schools(tarjan缩点)
- POJ1236 Network of Schools(tarjan缩点)
- POJ 1236 Network of Schools(强连通 Tarjan+缩点)
- poj 1236 Network of Schools 1 (tarjan 缩点)
- POJ 1236 Network of Schools(Tarjan + 缩点)
- POJ 1236 Network of Schools(强连通 Tarjan+缩点)
- POJ 1236 Network Of Schools ( tarjan求强连通分量 + 缩点成DAG图 )
- poj 1236 Network of Schools(tarjan 缩点)
- Network of Schools - POJ 1236 Tarjan 缩点
- 强连通分量,Tarjan,缩点(Network of Schools,POJ 1236)
- POJ 1236 Network of Schools (tarjan求强连通,缩点)
- POJ 1236 Network of Schools【强连通分量分解&&缩点||tarjan&&缩点】
- POJ 1236 Network of Schools(Tarjan Algorithm求强连通子集,缩点后DAG上出或入度为0的点)
- POJ 1236 Network of Schools(Tarjan + 缩点 + 计算出度and入度)
- POJ 1236 Network of Schools(tarjan)题解
- POJ 1236 Network of Schools 强连通图 tarjan
- POJ 1236 Network of Schools【强连通缩点】【Tarjan算法】
- 【POJ 1236】Network of Schools(强连通分量_tarjan)