![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Tarjan
文章平均质量分 79
弱菜zc
打完这场就回老家结婚!
展开
-
hdu 3836 Equivalent Sets //tarjan+缩点
题目链接 题意:给n个点和m条有向边,问最少再加几条边使其变成强连通图。和hdu2767同样的解法。 #include #include #include #include #define N 22000 #define M 55000 using namespace std; struct node { int next,to; }e[M]; int head[N],cnt,原创 2016-04-25 10:42:39 · 493 阅读 · 0 评论 -
Tarjan&LCA题集
【HDU】 [强连通]: 1269 迷宫城堡 判断是否是一个强连通★ 2767Proving Equivalences 至少加几条边让整个图变成强连通★ 3836 Equivalent Sets 至少加几条边让整个图变成强连通★ 1827 Summer Holiday 传递的最小费用★★ 3072 Intelligence System 传递的最小费用★★ 38转载 2016-04-09 15:55:02 · 568 阅读 · 0 评论 -
poj 3180 The Cow Prom 强连通分量tarjan
题目链接:http://poj.org/problem?id=3180 题意:有N头奶牛,和M个绳索。每个绳索从一头奶牛处发出,射向另一头奶牛。现在奶牛们想要跳舞,如果沿着射向它的绳索往回找,找到另一头牛,并如此找下去,最后能找到自己发出的绳索,那么这头奶牛就跳舞成功了,并且在寻找过程中,串起来的这些奶牛属于同一个集合。问最后这M个绳索连出了几个集合? 就是求元素大于1的强连通分量数,原创 2016-05-17 21:24:13 · 611 阅读 · 0 评论 -
hdu 3861 The King’s Problem tarjan+缩点+最小路径覆盖
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3861 题意:有一个n个点m条边的有向图,把这个图分成几个区域,使得每个区域中的任意两点u, v要么u能到v,要么v能到u,求最少要分成几个区域。 将强连通分量缩点得到有向的树,即求这棵树的最少路径覆盖(点数 – 二分图的最大匹配) //#include #include #in原创 2016-05-18 12:54:12 · 515 阅读 · 0 评论 -
hdu 1269 迷宫城堡 Tarjan算法
题目链接 题意:给出n个节点和m条边,判断这张图是不是强连通图。 第一次学习Tarjan算法,以下是Tarjan算法模板。 #include #include #include #include #define N 11000 #define M 110000 using namespace std; struct node { int next,v; }e[M]; int原创 2016-04-22 19:59:45 · 758 阅读 · 0 评论 -
hdu 2767 Proving Equivalences //tarjan+缩点
题目链接 题意:给n个点和m条有向边,问最少再加几条边使其变成强连通图。 先tarjan跑一遍,如果是强连通图就输出0。否则输出max(入度为0的点个数,出度为0的点个数)。 #include #include #include #include #define N 22000 #define M 55000 using namespace std; struct node {原创 2016-04-22 21:55:31 · 550 阅读 · 0 评论 -
poj 3352 Road Construction 双连通分量+缩点 模板
题目链接:http://poj.org/problem?id=3352 题意:给出一个没有重边的无向图,求至少加入几条边使整个图成为一个边双连通分量。 双连通分量模板,把图中所有的边双连通分量缩成一个点,原图就缩成了一棵树,要加的边数就是(所有度为1的点的个数 + 1)/2。 #include #include #include #include #include #def原创 2016-05-19 20:32:44 · 611 阅读 · 0 评论 -
【2017新疆网络赛】F Islands 强连通分量tarjan hdu2767原题
On the mysterious continent of Tamriel, there is a great empire founded by human. To develope the trade, the East Empire Company is set up to transport goods from place to place. Recently, the compa原创 2017-09-15 19:29:01 · 692 阅读 · 0 评论