POJ 1236 Network of Schools (Tarjan + 缩点)
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 12240 | Accepted: 4871 |
Description
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.
Input
Output
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算法
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。