![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
图论--强连通
文章平均质量分 72
fire__ice
这个作者很懒,什么都没留下…
展开
-
NYOJ 247虚拟城市之旅(强连通缩点 + 搜索)
题目连接:http://acm.nyist.edu.cn/JudgeOnline/problem.php?pid=247分析:为了解决环的问题,可以进行强连通缩点建图,可以记录一下每个强连通中商品能达到的最大值和最小值,然后在缩过点的无环图上搜索,在搜索路径上不断更新商品最小值与最大差值,如果能到达终点更新最大利润。参考代码如下: #include #include #inc原创 2012-05-03 10:41:52 · 977 阅读 · 0 评论 -
强连通、强连通缩点建图
#include #include #include #include using namespace std;#define CLR(arr,v) memset(arr,v,sizeof(arr))const int MaxV = 105,MaxE = 10005;int Connect[MaxV],H[MaxV],Num[MaxE],Next[MaxE],Len[MaxE],原创 2012-05-04 19:38:38 · 1008 阅读 · 0 评论 -
强连通模板(Tarjan)
使用说明:需要邻接表模板 ,头文件string.h 宏定义#define CLR(arr,v) memset(arr,v,sizeof(arr))const int M = 105 ;Graph g;int Connect[M],Low[M],Ind[M],Stack[M],InStack[M],ConnectNum,top,ind;void Dfs(int cur){ Low原创 2012-05-11 16:38:08 · 758 阅读 · 0 评论 -
NYOJ 120 校园网络(强连通缩点)
题目连接:http://acm.nyist.edu.cn/JudgeOnline/problem.php?pid=120解析:因为图中有环,环可以看做一个点,所以利用强连通缩点之后,在一个有向无环图上就好弄了,只用找一下入度为零的点的个数 和 出度为零的点的个数,较大的就是所求解,因为要消除所有入度和出度为零的点,所以出度为零的点到入度为零的点建边,哪种度为零的点剩余,就从这些点随便建边,所以原创 2012-05-04 17:19:27 · 961 阅读 · 0 评论 -
强连通缩点
使用说明:需要邻接表模板,强连通模板,头文件string.h 宏定义#define CLR(arr,v) memset(arr,v,sizeof(arr))在执行强连通模板后,执行缩点模板把缩过点后的图存到邻接表g1中。Graph g1;void BuiltGraph(int n){ g1.Clear(); for(int i = 1;i <= n;++i) for(int原创 2012-05-11 16:41:28 · 768 阅读 · 0 评论