图的连通性
KIDGINBROOK
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
zoj 1119 SPF 无向图割点
题目大意:找出一个网络中的spf点,即割点,并输出将某spf点删除后会将原网络分割成几个连通的子网络。 即求割点,用tarjan算法。 #include #include int min(int a,int b) { if(a<b) return a; else return b; } int Edge[1001][1001]; int vis[1001]; i原创 2013-10-29 12:15:58 · 675 阅读 · 0 评论 -
hdu 3313 Key Vertex
一个有向图,给定起点和终点,问他的割点数,割点是指去掉这个点能使得s和t不通。s和t也是割点。 先找一条从s到t的任意路径,假如没有路的话,那么割点数为n,如果找到了一条路径的话,将这条路径上的点标记出来,首先明确一点,割点肯定不会再路径外的点上,因为去掉外面的点后,还是有刚刚那条路径的。所以现在就要看路径上的每个点是不是割点。只要把路径上的点去掉,然后从s进行bfs,路径上的点不能走,这样进行原创 2014-12-15 10:53:10 · 490 阅读 · 0 评论 -
poj 3683 Priest John's Busiest Day 2-sat
#include #include #include #include #include using namespace std; const int maxn = 2000 + 30; vector G[maxn], G2[maxn]; vector S; int vis[maxn], sccno[maxn], scc_cnt; int n,m; int s[maxn],t[maxn],d[原创 2014-12-15 10:51:41 · 487 阅读 · 0 评论 -
poj 1904 King's Quest 强连通
朴素的想法,对于每个王子,原创 2014-06-10 21:27:42 · 530 阅读 · 0 评论 -
cf 244c Checkposts 强连通分量
#include #include #include #include #include using namespace std; #define maxn 100000 + 10 #define modu 1000000007 #define INF 2000000000 vector G[maxn], G2[maxn]; vector S; int vis[maxn], sccno[max原创 2014-05-04 20:33:54 · 560 阅读 · 0 评论 -
Codeforces Round #236 (Div. 2) E. Strictly Positive Matrix 强连通
题目大概意思是给定一个矩阵A,每个元素都非负,主对角线上元素大于0,问是否存在常数k,使得A的k次幂的每个元素都大于0。 由A的k次幂联想到离散数学中的可达性矩阵,即问是否存在常数k,使得任意两点之间都存在长度为k的路径,因为主对角线上严格大于0,也就是说有自环,所以只要该图是强联通的即可满足,因为若任意两点之间都能走到,那么配合自环就能找到一个共同的长度k。 #include #includ原创 2014-03-17 17:46:02 · 554 阅读 · 0 评论 -
poj 2186 Popular Cows 强连通
#include #include #include #include #include using namespace std; const int maxn = 10000 + 10; vector G[maxn], G2[maxn]; vector S; int vis[maxn], sccno[maxn], scc_cnt; int max(int a,int b) { if(a>原创 2014-02-08 21:52:31 · 569 阅读 · 0 评论 -
poj1236 Network of Schools 强连通分量
#include #include #include #include #include using namespace std; const int maxn = 100 + 10; vector G[maxn], G2[maxn]; vector S; int vis[maxn], sccno[maxn], scc_cnt; int in[maxn],out[maxn]; int max原创 2014-02-02 12:40:19 · 605 阅读 · 0 评论 -
poj 3177 Redundant Paths 边双连通
出自http://blog.youkuaiyun.com/wangjian8006/article/details/7990666# #include using namespace std; #define MAXV 5010 #define min(a,b) (a>b?b:a) int n,m; bool map[MAXV][MAXV]; bool vis[MAXV]; int low[MAXV],转载 2014-01-30 15:21:14 · 543 阅读 · 0 评论 -
poj 2942 Knights of the Round Table 双连通分量
白书上的代码 #include #include #include #include #include using namespace std; struct Edge { int u, v; }; const int maxn = 1000 + 10; int pre[maxn], iscut[maxn], bccno[maxn], dfs_clock, bcc_cnt; // 割顶的b原创 2014-01-11 10:45:52 · 603 阅读 · 0 评论 -
zoj 2588 Burning Bridges 桥
#include #include #define clr(a) memset(a,0,sizeof(a)) #define N 10005 #define M 100005 int MIN(int a,int b) { if(a<b) return a; else return b; } struct Node { int j,tag,id; Node *next; }; int n原创 2014-01-11 10:38:11 · 623 阅读 · 0 评论 -
poj 1966 Cable TV Network 点连通度
#include #include #define Max 300 #define INF 5000000 int flow[Max][Max],d[Max]; int map[Max][Max]; int sta,end; int m,n; int min(int a,int b) { if(a<b) return a; else return b; } bool bfs(原创 2013-12-17 20:38:56 · 756 阅读 · 0 评论 -
hdu 4587 TWO NODES 关节点
#include #include #include using namespace std; #define maxn 5020 vector g[maxn]; int pre[maxn],low[maxn],iscut[maxn]; int n,m; int dfs_clock; int del; int min(int a,int b) { if(a<b) return a;原创 2013-12-08 15:21:39 · 677 阅读 · 0 评论 -
Kosaraju算法的分析和证明 转自http://blog.sina.com.cn/s/blog_4dff87120100r58c.html
Kosaraju算法是求解有向图强连通分量(strong connected component)的三个著名算法之一,能在线性时间求解出一个图的强分量。用Sedgewick爷爷的话说,就是“现代算法设计的胜利”。 什么是强连通分量?在这之前先定义一个强连通性(strong connectivity)的概念:有向图中,如果一个顶点s到t有一条路径,t到s也有一条路径,即s与t互相可达,那么我们说s转载 2013-12-09 11:27:45 · 983 阅读 · 0 评论 -
hdu 2767 Proving Equivalences 强连通
#include #include #include #include #include using namespace std; const int maxn = 20000 + 10; vector G[maxn], G2[maxn]; vector S; int vis[maxn], sccno[maxn], scc_cnt; void dfs1(int u) { if(vi原创 2013-12-08 15:23:46 · 627 阅读 · 0 评论 -
codeforces 894E Ralph and Mushrooms 强连通dp
E. Ralph and Mushrooms time limit per test 2.5 seconds memory limit per test 512 megabytes input standard input output standard output Ralph is going to collect mushrooms in the Mushroom Fore...原创 2018-10-11 13:50:58 · 424 阅读 · 0 评论
分享