Network of Schools Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 16806   Accepted: 6643 Description A number of schools are connected to a computer network. Agreements have been developed among those schools: each school maintains a li…
Network of Schools Description 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…
Network of Schools 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 t…
题意: 求一个有向图中: (1)要选几个点才能把的点走遍 (2)要添加多少条边使得整个图强联通 分析: 对于问题1, 我们只要求出缩点后的图有多少个入度为0的scc就好, 因为有入度的scc可以从其他地方到达. 对于问题2, 每个入度为0的scc, 都可以补一条边可以变成强连通图, 每个出度为0的scc, 也可以补一条边使其变成强连通图. 所以答案就是max(入度为0scc个数,出度为0scc个数). #include<cstdio> #include<iostream> #inc…
Network of Schools Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 22745   Accepted: 8929 Description A number of schools are connected to a computer network. Agreements have been developed among those schools: each school maintains a li…
Network of Schools Description 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…
题意:一个有向图.第一问:最少给几个点信息能让所有点都收到信息.第二问:最少加几个边能实现在任意点放信息就能传遍所有点 思路:把所有强连通分量缩成一点,然后判断各个点的入度和出度 tarjan算法:问问神奇海螺啥是tarjan 代码: #include<cstdio> #include<cstring> #include<cstdlib> #include<cctype> #include<queue> #include<cmath>…
题目链接:http://poj.org/problem?id=1236 题目大意: 给你一个网络(有向图),有两个任务: ①求出至少同时需要几份副本可以使得整个网络都获得副本 ②至少添加多少信息表(有向边)使得副本传到任一点,都可以使得整个网络都获得副本 解题思路: 即给定一个有向图,求: ①至少要选几个顶点,才能做到从这些顶点出发,可以到达全部顶点 ②至少要加多少条边,才能使得从任何一个顶点出发,都能到达全部顶点缩点后,分别求出出度入度为0的点数为sum1,sum2,问题①的答案就为sum2;…
思路:使用tarjan求强连通分量并进行缩点,判断所有入度为0的点,这个点就是必须要给予文件的点,分别计算出度,入度为零的点的个数,取二者的最大值就是把这个图变成强连通需要加的边数. 一个取值需要讨论,当这个图就是强连通图的时候,答案输出1和0. 个人经历:作为初学者这个题错了很多遍,学姐给我们讲的在某个点已经被访问过的时候low值是否更新的问题,使用的是id的判断方法,只有当id为零的时候才能更新low值,这个现在我是理解的,但当时因为错误太多看别人的代码时,看到了是否在栈中的记录方式,当时我…
题目链接:http://poj.org/problem?id=1236 题意: 本题为有向图. 需解决两个问题: 1 须要给多少个点,才干传遍全部点. 2 加多少条边,使得整个图变得强连通. 使用Tarjan进行缩点,得到一个SCC图. 这个图有多少个入度为0的,多少个出度为0的. 如果有n个入度为0,m个出度为0 那么第一个答案就是n,第二个答案是max(n,m) 代码: #include <stdio.h> #include <iostream> #include <ma…