求割点 模板

 1 void dfs(int u,int father)
 2 {
 3     int child=0;
 4     dfn[u]=low[u]=++dfs_clock;
 5
 6     for (int c=head[u];c;c=nxt[c])
 7     {
 8         int v=to[c];
 9         if (!dfn[v])
10         {
11             child++;
12             dfs(v,u);
13             low[u]=min(low[u],low[v]);
14             if (low[v]>=dfn[u])
15                 is_cut[u]=true;
16         }
17         else if (v!=father)
18             low[u]=min(low[u],dfn[v]);
19     }
20
21     if (!father && child==1)
22         is_cut[u]=0;
23 }
时间: 2024-08-29 03:22:41

求割点 模板的相关文章

Poj 1144 Zoj 1311 求割点 模板

写这个就是为了手写一份好用的求割点模板: 吐槽下,题目中的 Each of the next at most N lines contains the number of a place followed by the numbers of some places to which there is a direct line from this place.  这个at most是不可信的,应该是用大于n行的测试数据,因为这个我WA了... #include <cstdio> #includ

poj1144Network (求割点模板题)

题目连接 题意:给出一个无向图,求出割点的个数 code: #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <vector> #define maxn 100005 using namespace std; vector<int> G[maxn]; int dfn[maxn],vis[maxn],low[max

poj1144 tarjan求割点 裸题

Network Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 11684   Accepted: 5422 Description A Telephone Line Company (TLC) is establishing a new telephone cable network. They are connecting several places numbered by integers from 1 to N

【lightoj-1063】Ant Hills(求割点)

求割点模板题 #include <bits/stdc++.h> using namespace std; const int N = 10004; int dfn[N], low[N]; bool ok[N]; vector<int>V[N]; int n, num, root; void dfs(int s, int f) { low[s] = dfn[s] = ++num; int child = 0; for(unsigned int i = 0; i < V[s].s

连通分量模板:tarjan: 求割点 &amp;&amp; 桥 &amp;&amp; 缩点 &amp;&amp; 强连通分量 &amp;&amp; 双连通分量 &amp;&amp; LCA(最近公共祖先)

PS:摘自一不知名的来自大神. 1.割点:若删掉某点后,原连通图分裂为多个子图,则称该点为割点. 2.割点集合:在一个无向连通图中,如果有一个顶点集合,删除这个顶点集合,以及这个集合中所有顶点相关联的边以后,原图变成多个连通块,就称这个点集为割点集合. 3.点连通度:最小割点集合中的顶点数. 4.割边(桥):删掉它之后,图必然会分裂为两个或两个以上的子图. 5.割边集合:如果有一个边集合,删除这个边集合以后,原图变成多个连通块,就称这个点集为割边集合. 6.边连通度:一个图的边连通度的定义为,最

Tarjan求强连通分量、求桥和割点模板

Tarjan 求强连通分量模板.参考博客 #include<stdio.h> #include<stack> #include<algorithm> using namespace std; const int maxn = 1e3 + 10; const int maxm = 330000 + 10; struct EDGE{ int v, nxt; }Edge[maxm]; int Head[maxn], cnt; int DFN[maxn], LOW[maxn],

tarjan双联通求割点和桥模板

  求割点 int n,m,stamp,low[1005],dfn[1005],iscut[1005];//iscut记录的为割点 vector<int> vec[1005]; void tarjan(int index,int fa){ int child=0; low[index]=dfn[index]=++stamp; for(int i=0;i<vec[index].size();i++) { int tmp=vec[index][i]; if(!dfn[tmp]) { chil

(连通图 模板题 无向图求割点)Network --UVA--315(POJ--1144)

链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=251 http://poj.org/problem?id=1144 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82833#problem/B 代码: #include<cstdio> #include<

tarjan算法求割点cojs 8

tarjan求割点:cojs 8. 备用交换机 ★★   输入文件:gd.in   输出文件:gd.out   简单对比时间限制:1 s   内存限制:128 MB [问题描述] n个城市之间有通讯网络,每个城市都有通讯交换机,直接或间接与其它城市连接.因电子设备容易损坏,需给通讯点配备备用交换机.但备用交换机数量有限,不能全部配备,只能给部分重要城市配置.于是规定:如果某个城市由于交换机损坏,不仅本城市通讯中断,还造成其它城市通讯中断,则配备备用交换机.请你根据城市线路情况,计算需配备备用交换