时间复杂度:O(n玄学)总之不大

代码实现(好麻烦,蓝题变紫题)

 #include<iostream>
#include<string.h>
#include<algorithm>
#include<vector>
#include<map>
#include<bitset>
#include<set>
#include<string>
#if !defined(_WIN32)
#include<bits/stdc++.h>
#endif // !defined(_WIN32)
#define ll long long
#define dd double
using namespace std;
int n, m;
int tot;
ll ans;
struct edge
{
bool t;
bool flag;
int to;
int num;
int next;
}e[];
struct node
{
int son;
bool flag;
int f;
int head;
int d;
int deep;
}p[];
int vis[];
void add(int x, int y)
{
tot++;
e[tot].to = y;
e[tot].next = p[x].head;
p[x].head = tot;
}
bool check(int x)
{
for (int i = p[x].head; i; i = e[i].next)
{
if (e[i].flag && !e[i].t)
{
int to = e[i].to;
if (!(p[to].d < p[x].deep))
return ;
}
}
return ;
}
void dfs(int x, int f)
{
vis[x] = ;
p[x].deep = p[f].deep + ;
p[x].d = p[x].deep;
for (int i = p[x].head; i; i = e[i].next)
{
int to = e[i].to;
if (!vis[to])
{
p[x].son++;
p[to].f = x;
e[i].flag = ;
dfs(to, x);
}
}
}
void init(int x)
{
for (int i = p[x].head; i; i = e[i].next)
{
int to = e[i].to;
if (e[i].flag && !e[i].t)
{
init(to);
p[x].d = min(p[x].d, p[to].d);
}
}
}
void work()
{
for (int x = ; x <= n; x++)
{
if (x == )
{
if (p[x].son <= )
p[x].flag = ;
}
else if (p[x].son == )
{
p[x].flag = ;
}
else
{
if (check(x))
p[x].flag = ;
}
}
}
int main()
{
cin >> n >> m;
for (int i = ; i <= m; i++)
{
int x, y;
cin >> x >> y;
add(x, y);
add(y, x);
}
dfs(, );
for (int i = ; i <= n; i++)
{
for (int j = p[i].head; j; j = e[j].next)
{
int to = e[j].to;
if (!e[j].flag && to != p[i].f)
{
p[i].d = min(p[i].d, p[to].deep);
}
else if (to == p[i].f)
{
e[j].t = ;
}
}
}
init();
work();
for (int i = ; i <= n; i++)
{
if (!p[i].flag)
cout << i << endl;
}
return ;
}

DFS树求割点问题的更多相关文章

  1. 【bzoj2115】[Wc2011] Xor DFS树+高斯消元求线性基

    题目描述 输入 第一行包含两个整数N和 M, 表示该无向图中点的数目与边的数目. 接下来M 行描述 M 条边,每行三个整数Si,Ti ,Di,表示 Si 与Ti之间存在 一条权值为 Di的无向边. 图 ...

  2. Tarjan应用:求割点/桥/缩点/强连通分量/双连通分量/LCA(最近公共祖先)【转】【修改】

    一.基本概念: 1.割点:若删掉某点后,原连通图分裂为多个子图,则称该点为割点. 2.割点集合:在一个无向连通图中,如果有一个顶点集合,删除这个顶点集合,以及这个集合中所有顶点相关联的边以后,原图变成 ...

  3. (转)Tarjan应用:求割点/桥/缩点/强连通分量/双连通分量/LCA(最近公共祖先)

    基本概念: 1.割点:若删掉某点后,原连通图分裂为多个子图,则称该点为割点. 2.割点集合:在一个无向连通图中,如果有一个顶点集合,删除这个顶点集合,以及这个集合中所有顶点相关联的边以后,原图变成多个 ...

  4. uva 315 Network(无向图求割点)

    https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  5. poj 1144 (Tarjan求割点数量)

    题目链接:http://poj.org/problem?id=1144 描述 一个电话线公司(简称TLC)正在建立一个新的电话线缆网络.他们连接了若干个地点分别从1到N编号.没有两个地点有相同的号码. ...

  6. UVA 315 Network (模板题)(无向图求割点)

    <题目链接> 题目大意: 给出一个无向图,求出其中的割点数量. 解题分析: 无向图求割点模板题. 一个顶点u是割点,当且仅当满足 (1) u为树根,且u有多于一个子树. (2) u不为树根 ...

  7. 求割点 割边 Tarjan

    附上一般讲得不错的博客 https://blog.csdn.net/lw277232240/article/details/73251092 https://www.cnblogs.com/colle ...

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

    链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  9. B - Network---UVA 315(无向图求割点)

        A Telephone Line Company (TLC) is establishing a new telephone cable network. They are connectin ...

随机推荐

  1. Tomcat CGIServlet enableCmdLineArguments远程代码执行_CVE-2019-0232漏洞复现

    Tomcat CGIServlet enableCmdLineArguments远程代码执行_CVE-2019-0232漏洞复现 一.漏洞描述 该漏洞是由于tomcat CGI将命令行参数传递给Win ...

  2. Ubuntu中目录右下角的锁标志

    在ubuntu中如果是用root权限创建的目录,在普通权限下展示时则会出现一个锁的标志,表明该目录是一个受保护的目录(只读,不能写入和删除),普通权限无法对其进行操作.如用命令sudo mkdir d ...

  3. MYSQL数据库的安装,配置文件,登入

    07.13自我总结 MYSQL数据库 一.MYQL数据库的安装 可以去mysql官网下载mysql压缩包 运行程序:在bin文件夹中,其中客户端运行文件是mysql.exe,服务端运行文件为mysql ...

  4. CentOS虚拟机查询jdk路径

    [root@wshCentOS ~]# which java/usr/bin/java[root@wshCentOS ~]# ls -lrt /usr/bin/javalrwxrwxrwx. 1 ro ...

  5. sql server还原数据库(请选择用于还原的备份集)

    还原数据库的时候明明选择了备份集,还是提示未选择还原的备份集 后来查了下,是因为我本地有两个数据库(2008R2和2014),对应的两个数据库实例.而还原bak是sqlserver2014的备份,我默 ...

  6. WAMP运行原理

    Apache运行原理 Apache的诸多功能都是通过模块进行加载的,自己本身并不具备那么多功能. php文件动态网页请求原理 请求步骤: 1. 用户在浏览器中输入需要访问的网站的域名以及具体要请求的网 ...

  7. SQL语句中的as

  8. 思路重要or技术重要?

    1,思路串通代码的重要性 前段时间,同事在工作上出现一点难题,在技术大佬中看起来算是微不足道的一点小事,由于没有思路,代码也无从下手,他在百度上条框上搜索自己想要的答案,却始终没有比较理想的,大部分的 ...

  9. 【Python-django后端开发】logging日制配置详解!!!

    官方文档请查看:https://docs.djangoproject.com/en/1.11/topics/logging/ 1. 配置工程日志,在setting.py里,如下 LOGGING = { ...

  10. 基于SpringBoot从零构建博客网站 - 集成editor.md开发发布文章功能

    发布文章功能里面最重要的就是需要集成富文本编辑器,目前富文本编辑器有很多,例如ueditor,CKEditor.editor.md等.这里守望博客里面是集成的editor.md,因为editor.md ...