图论
weixin_45888462
这个作者很懒,什么都没留下…
展开
-
Tarjan算法
缩点 题目链接 解题步骤 链式前向星初始化有向有环图 使用Tarjan算法缩环为点 重新构建图(有向无环图) 拓扑排序加dp求最大权值 第二步Tarjan详解 dfn数组表示先根遍历编号 代码 #include <bits/stdc++.h> using namespace std; const int maxn=10005; const int maxm=100005; int n,m,w[maxn],ans; struct node { int from,to,next原创 2020-07-09 18:43:03 · 91 阅读 · 0 评论 -
欧拉回路
题目链接 欧拉回路解题思路 并查集判断图连通性 degree数组记录顶点度数判断欧拉性 图用邻接矩阵存储 path数组记录路径 解题步骤 初始化图和并查集 用并查集计数连通分量判断图连通性 degree数组统计度数为奇数的点,顺便找出起点位置 dfs求欧拉回路,逐步删边,回溯记录路径 代码 #include <bits/stdc++.h> using namespace std; const int maxn=260; int n,start,p;原创 2020-07-09 10:30:07 · 69 阅读 · 0 评论