洛谷P3388

注意:记得tarjan的打法

   注意割点的判断条件:子节点个数>2并且为根节点

               当它不为根节点时并且low[to]>dfn[u]

   判断时是在子节点未被记录的时候

 #include<bits/stdc++.h>
using namespace std;
inline int sc()
{ int x=,f=;char ch=getchar();
while(!isdigit(ch)){ if(ch==)f=-;ch=getchar();}
while(isdigit(ch)) { x=x*+ch-;ch=getchar();}
return x*f;
}
#define man 100010
int n,m;
/*edge*/
int head[man<<],num=;
struct edge
{ int next,to;}e[man<<];
inline void add(int from,int to)
{ e[++num].next=head[from];
e[num].to=to;
head[from]=num;
} int dep=,dfn[man],low[man],cnt=;
bool vis[man],sta[man];
inline void tarjan(int u,int fa)
{ int son=;
low[u]=dfn[u]=++dep;
for(int i=head[u];i;i=e[i].next)
{ int to=e[i].to;
if(!dfn[to])
{ son++;
tarjan(to,u);
low[u]=min(low[u],low[to]);
if((fa==-&&son>=)||(fa!=-&low[to]>=dfn[u]))
{ if(sta[u]==) cnt++;sta[u]=;}
}
else if(to!=fa)
low[u]=min(low[u],dfn[to]);
}
}
int main()
{ n=sc();m=sc();
for(int i=,x,y;i<=m;i++)
{ x=sc(),y=sc();
add(x,y);add(y,x);
}
for(int i=;i<=n;i++)
if(!dfn[i]) tarjan(i,-);
cout<<cnt<<endl;
for(int i=;i<=n;i++)
if(sta[i]) cout<<i<<" ";
cout<<endl;
return ;
}

[模板]割点(tarjan)的更多相关文章

  1. 洛谷3388 【模板】割点 tarjan算法

    题目描述 给出一个n个点,m条边的无向图,求图的割点. 关于割点 在无向连通图中,如果将其中一个点以及所有连接该点的边去掉,图就不再连通,那么这个点就叫做割点(cut vertex / articul ...

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

    PS:摘自一不知名的来自大神. 1.割点:若删掉某点后.原连通图分裂为多个子图.则称该点为割点. 2.割点集合:在一个无向连通图中,假设有一个顶点集合,删除这个顶点集合,以及这个集合中全部顶点相关联的 ...

  3. 图论--割点--Tarjan模板

    #include <iostream> #include <algorithm> #include <cstdio> #include <cstring> ...

  4. 【洛谷P3388】(模板)割点

    [模板]割点 割点集合:一个顶点集合V,删除该集合的所有定点以及与这些顶点相连的边后,原图不连通,就称集合V为割点集合 点连通度:最小割点集合中的顶点数 边连通度:最小割边集合中的边数 割点:割点集合 ...

  5. poj 1523 割点 tarjan

    Description Consider the two networks shown below. Assuming that data moves around these networks on ...

  6. 割点 —— Tarjan 算法

    由于对于这一块掌握的十分不好,所以在昨天做题的过程中一直困扰着我,好不容易搞懂了,写个小总结吧 qwq~ 割点 概念 在无向连通图中,如果将其中一个点以及所有连接该点的边去掉,图就不再连通,那么这个点 ...

  7. poj1523 求割点 tarjan

    SPF Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 7678   Accepted: 3489 Description C ...

  8. POJ 1470 Closest Common Ancestors (模板题)(Tarjan离线)【LCA】

    <题目链接> 题目大意:给你一棵树,然后进行q次询问,然后要你统计这q次询问中指定的两个节点最近公共祖先出现的次数. 解题分析:LCA模板题,下面用的是离线Tarjan来解决.并且为了代码 ...

  9. POJ 1523 SPF 割点 Tarjan

    SPF Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9317   Accepted: 4218 Description C ...

随机推荐

  1. Unit08: Spring集成mybatis

    Unit08: Spring集成mybatis 1. Spring集成mybatis (1)方式一 step1. 导包. spring-webmvc,mybatis,mybatis-spring, o ...

  2. 历届试题 Excel地址

    问题描述 Excel单元格的地址表示很有趣,它使用字母来表示列号. 比如, A表示第1列, B表示第2列, Z表示第26列, AA表示第27列, AB表示第28列, BA表示第53列, .... 当然 ...

  3. 【JS】手机屏幕旋转判断

    function readDeviceOrientation() { if (Math.abs(window.orientation) === 90) { // Landscape alert('横屏 ...

  4. Django 的ORM

    指定字段: <1> CharField:字符串字段,用于较短的字符串,CharField 要求必须有一个参数 maxlength,用于从数据库层和Django效验层限制该字段所允许的最大字 ...

  5. python多标签分类模版

    from sklearn.multioutput import MultiOutputClassifier from sklearn.ensemble import RandomForestClass ...

  6. Clustering Factor——索引的成本指标

    使用索引是我们面对海量数据搜索是一种常用的手段.通过有效的索引访问,可以使我们更快的访问到需要的数据,减少物理.逻辑IO,从而提高系统性能.在CBO时代,Oracle对于提交SQL的执行路径是有所选择 ...

  7. 在线pubmed

    ESearch(文本搜索) eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi http://eutils.ncbi.nlm.nih.gov/entr ...

  8. linux下启动关闭oracle

    1. linux下启动oracle su - oracle sqlplus /nolog conn /as sysdba startup exit lsnrctl start 2. linux下关闭o ...

  9. scp 远程复制

    1. 上传本地文件到远程机器指定目录 命令: scp /opt/soft/nginx-0.5.38.tar.gz root@192.168.120.204:/opt/soft/scptest 上传本地 ...

  10. msyqld 的 The user specified as a definer ('root'@'%') does not exist 问题

    msyqld 的 The user specified as a definer ('root'@'%') does not exist 问题 造成问题:搭建网站时显示内容不完整. 跟踪tomcat日 ...