摘要: 题目地址:http://poj.org/problem?id=2553The Bottom of a GraphTime Limit:3000MSMemory Limit:65536KTotal Submissions:7881Accepted:3263DescriptionWe will use the following (standard) definitions from graph theory. LetVbe a nonempty and finite set, its elements being called vertices (or nodes). LetEbe a subs 阅读全文
posted @ 2013-08-10 18:00 crazy_apple 阅读(255) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=2186Popular CowsTime Limit:2000MSMemory Limit:65536KTotal Submissions:20191Accepted:8193DescriptionEvery cow's dream is to become the most popular cow in the herd. In a herd of N (1 7 #include 8 #include 9 #include 10 #include 11 #include 12 13 #define N 10010 14 using. 阅读全文
posted @ 2013-08-10 17:16 crazy_apple 阅读(216) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 8 #define N 1000 9 10 using namespace std;11 12 int pre[N],lowlink[N],sccno[N],dfn_clock,scc_cnt;13 14 stack stk;15 16 vector G[N];17 18 void DFN(int u)19 {20 pre[u] = lowlink[u] = ++dfn_clock; //时间戳21 stk.push(u);22 ... 阅读全文
posted @ 2013-08-10 11:50 crazy_apple 阅读(189) 评论(0) 推荐(0) 编辑
摘要: 有向图强连通分量的Tarjan算法[有向图强连通分量]在有向图G中,如果两个顶点间至少存在一条路径,称两个顶点强连通(strongly connected)。如果有向图G的每两个顶点都强连通,称G是一个强连通图。非强连通图有向图的极大强连通子图,称为强连通分量(strongly connected components)。下图中,子图{1,2,3,4}为一个强连通分量,因为顶点1,2,3,4两两可达。{5},{6}也分别是两个强连通分量。直接根据定义,用双向遍历取交集的方法求强连通分量,时间复杂度为O(N^2+M)。更好的方法是Kosaraju算法或Tarjan算法,两者的时间复杂度都是O(N 阅读全文
posted @ 2013-08-10 11:48 crazy_apple 阅读(192) 评论(0) 推荐(0) 编辑