摘要: 1 // include file 2 #include <cstdio> 3 #include <cstdlib> 4 #include <cstring> 5 #include <cmath> 6 #include <cctype> 7 #include <ctime> 8 9 #include <iostream> 10 #include <sstream> 11 #include <fstream> 12 #include <iomanip> 13 #include 阅读全文
posted @ 2011-02-27 23:25 AC2012 阅读(188) 评论(0) 推荐(0) 编辑
摘要: Tarjan's strongly connected components algorithmPku 2186,2553,1236,2762,都是可以用强连通分量算法来解决的。Kosaraju的算法在大部分情况下还是够用的,至少对于这四个题时间都还行。但是既然有更好的算法,那也学习一下吧。Thealgorithm takes a directedgraph as input, and produces a partition of the graph's vertices into the graph's strongly connectedcomponents. E 阅读全文
posted @ 2011-02-27 23:01 AC2012 阅读(622) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 此题,可用强连通分量算法缩图,然后拓扑排序判断是否为链。 3 */ 4 // include file 5 #include <cstdio> 6 #include <cstdlib> 7 #include <cstring> 8 #include <cmath> 9 #include <cctype> 10 #include <ctime> 11 12 #include <iostream> 13 #include <sstream> 14 #include <fstream& 阅读全文
posted @ 2011-02-27 19:53 AC2012 阅读(250) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 用到强连通分量算法,缩图。构建新图,查看出度为0的点和入度为0的点 3 问题1的答案很明显,入度为0的点是必须先发布给它的 4 问题2的答案,猜测是这样的。要想全连通,即任何一个学校到另外一所 5 学校都有路径,那么所有的节点都必须有入和出,不能出现入度和出度为0 6 的情况,所以最好的答案就是入度和出度的最大值了。 7 */ 8 // include file 9 #include <cstdio> 10 #include <cstdlib> 11 #include <cstring> 12 #include <cmath> 13 阅读全文
posted @ 2011-02-27 17:08 AC2012 阅读(810) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 用到强连通分量算法,缩图。构建新图,查看出度为0的点,可以有多个出度为0的点 3 */ 4 // include file 5 #include <cstdio> 6 #include <cstdlib> 7 #include <cstring> 8 #include <cmath> 9 #include <cctype> 10 #include <ctime> 11 12 #include <iostream> 13 #include <sstream> 14 #include &l 阅读全文
posted @ 2011-02-27 15:54 AC2012 阅读(767) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 主要用到强连通分量,缩图。判断某个点(缩点后)的出度为0的那个点的大小。即那个强连通分量的大小。出度为0的点只能有1个或者0个。不可能为多个,否则就不会被所有的其他的点所到达 3 */ 4 // include file 5 #include <cstdio> 6 #include <cstdlib> 7 #include <cstring> 8 #include <cmath> 9 #include <cctype> 10 #include <ctime> 11 12 #include <iostre 阅读全文
posted @ 2011-02-27 15:14 AC2012 阅读(513) 评论(0) 推荐(0) 编辑