#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <stack>
using namespace std;
const int N=100010;
int head[N],ver[N*2],Next[N*2];
int dfn[N],low[N],n,m,tot,num;
bool brige[N*2];
void add(int x,int y){
ver[++tot]=y,Next[tot]=head[x],head[x]=tot;
}
void tarjan(int x,int inedge)
{ dfn[x]=low[x]=++num;
for(int i=head[x];i;i=Next[i])
{
int y=ver[i];
if(!dfn[y])
{
tarjan(y,i);
low[x]=min(low[x],low[y]);
if(low[y]>dfn[x])
{
brige[i]=brige[i^1]=1;
}
}
else if(i!=(inedge^1))
low[x]=min(low[x],dfn[y]);
}
}
int main()
{
cin>>n>>m;
tot=1;
for(int i=1;i<=m;i++)
{
int x,y;
scanf("%d %d",&x,&y);
add(x,y);
add(y,x);
}
for(int i=1 ;i<=n;i++)
if(!dfn[i]) tarjan(i,0);
int ans=0;
for(int i=2;i<tot;i+=2)
{
if(brige[i])
{
printf("%d %d\n",ver[i^1],ver[i]);
}
}
}

图论--割点--Tarjan模板的更多相关文章

  1. 图论算法-Tarjan模板 【缩点;割顶;双连通分量】

    图论算法-Tarjan模板 [缩点:割顶:双连通分量] 为小伙伴们总结的Tarjan三大算法 Tarjan缩点(求强连通分量) int n; int low[100010],dfn[100010]; ...

  2. 图论--割边--Tarjan模板

    #include<iostream> #include<stdio.h> #include<vector> using namespace std; const i ...

  3. 图论--割点--Tarjan

    #include<iostream> #include<stdio.h> #include<vector> using namespace std; const i ...

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

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

  5. poj 1523 割点 tarjan

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

  6. 学渣乱搞系列之Tarjan模板合集

    学渣乱搞系列之Tarjan模板合集 by 狂徒归来 一.求强连通子图 #include <iostream> #include <cstdio> #include <cs ...

  7. UOJ #146. 【NOIP2015】信息传递 连通分量 tarjan模板题

    http://uoj.ac/problem/146 题解:强连通分量 tarjan模板题.同时试了一下codeblock #include<bits/stdc++.h> using nam ...

  8. 洛谷1726 上白泽慧音 tarjan模板

    题目描述 在幻想乡,上白泽慧音是以知识渊博闻名的老师.春雪异变导致人间之里的很多道路都被大雪堵塞,使有的学生不能顺利地到达慧音所在的村庄.因此慧音决定换一个能够聚集最多人数的村庄作为新的教学地点.人间 ...

  9. 算法问题实战策略 MEETINGROOM 附一份tarjan模板

    地址 https://algospot.com/judge/problem/read/MEETINGROOM 解答  2-sat 代码样例过了 没有ac. 我又没有正确代码对拍..... 已确认是输出 ...

随机推荐

  1. docker-compose中加入nginx 日志和部署下载

    服务器部署了nginx镜像,所以加入一个日志查看,添加一下静态页面下载. 1.查看nginx镜像怎么部署的 nginx: image: nginx ports: - '80:80' volumes: ...

  2. 汇编 RET 和 CALL

    https://blog.csdn.net/u013018721/article/details/51264199 1.我们先来实践一下 ret 指令 DATA SEGMENT A DB 12H B ...

  3. Exercise 1测试

    此篇博客旨在测试Exercise 1,发现其中问题并解决. 首先,我们使用codeblocks对Exercise 1进行编译.结果如下: 可以发现经编译后的Exercise 1并无编译错误,只有两个w ...

  4. 基于 Jepsen 来发现几个 Raft 实现中的一致性问题(2)

    Nebula Graph 是一个高性能.高可用.强一致的分布式图数据库.由于 Nebula Graph 采用的是存储计算分离架构,在存储层实际只是暴露了简单的 kv 接口,采用 RocksDB 作为状 ...

  5. 37.2 net-- tcp传输 ServerSocket、Socket

    一.打开server端 package day35_net_网络编程.tcp传输; import java.io.IOException; import java.io.InputStream; im ...

  6. 配置spark历史服务(spark二)

    1. 编辑spark-defaults.conf位置文件 添加spark.eventLog.enabled和spark.eventLog.dir的配置修改spark.eventLog.dir为我们之前 ...

  7. tf.nn.softmax 分类

    tf.nn.softmax(logits,axis=None,name=None,dim=None) 参数: logits:一个非空的Tensor.必须是下列类型之一:half, float32,fl ...

  8. 一个不错的java学习博客

    http://iteye.blog.163.com/blog/static/18630809620131484835129/

  9. 02-css3之2D转换

    一.CSS3 -2D转换 转换(transform)可以实现元素的位移.旋转.缩放等效果.可以理解为变形. 1. 2D转换之移动translate 可以改变元素的页面中的位置,类似于定位. 1.1语法 ...

  10. D. AB-string

    https://codeforces.com/contest/1238/problem/D 题目大意:统计good string的个数,good string的定义,给定的字符串中含有回文段落, 题解 ...