博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UVA 610 Street Directions 双连通分量
阅读量:7143 次
发布时间:2019-06-29

本文共 1552 字,大约阅读时间需要 5 分钟。

首先找到全部双连通分量,然后对于某一个结点数大于2的连通分量,可以把全部的边改成单向的,按DFS的顺序。

结点数为2的也就是一条为桥的边,必须保持双向。

//#pragma comment(linker, "/STACK:1024000000,1024000000")#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;typedef long long ll;typedef unsigned long long ull;typedef pair
pii;#define pb(a) push(a)#define INF 0x1f1f1f1f#define lson idx<<1,l,mid#define rson idx<<1|1,mid+1,r#define PI 3.1415926535898template
T min(const T& a,const T& b,const T& c) { return min(min(a,b),min(a,c));}template
T max(const T& a,const T& b,const T& c) { return max(max(a,b),max(a,c));}void debug() {#ifdef ONLINE_JUDGE#else freopen("d:\\in1.txt","r",stdin); freopen("d:\\out1.txt","w",stdout);#endif}int getch() { int ch; while((ch=getchar())!=EOF) { if(ch!=' '&&ch!='\n')return ch; } return EOF;}struct Edge{ int u,v; Edge(int u,int v):u(u),v(v){}};const int maxn=1110;int pre[maxn],low[maxn],bccno[maxn];int bcc_cnt,dfs_clock;vector
g[maxn],bcc[maxn];stack
s,res;void dfs(int u,int fa){ low[u]=pre[u]=++dfs_clock; for(int i=0;i
=pre[u]) { bcc_cnt++; bcc[bcc_cnt].clear(); while(1) { Edge x=s.top();s.pop(); if(bccno[x.u]!=bcc_cnt) { bccno[x.u]=bcc_cnt; bcc[bcc_cnt].push_back(x.u); } if(bccno[x.v]!=bcc_cnt) { bccno[x.v]=bcc_cnt; bcc[bcc_cnt].push_back(x.v); } if(x.u==u&&x.v==v)break; } } }else if(pre[v]
View Code

 

转载于:https://www.cnblogs.com/BMan/p/3619336.html

你可能感兴趣的文章
关于设置http响应头connection的作用
查看>>
GCC的几个重要选项解释
查看>>
Java之注解
查看>>
PHP响应式VIP电影影视系统源码 带自动采集和会员管理系统
查看>>
iframe里弹出的层显示在整个网页上
查看>>
开源项目Bug悬赏任务
查看>>
ubuntu 和 win10 双系统安装 及 pyopengl 环境配置修改
查看>>
学习计划书
查看>>
为什么你的智能手表功能这么多,ICMAX来解答
查看>>
tor_api
查看>>
给国外电子邮箱发海外邮件用什么邮箱好?
查看>>
Connectify+Wireshark捕获手机APP的数据包
查看>>
CentOS 6.5 生产环境编译安装LNMP
查看>>
8.6 “数据库设置”服务器选项
查看>>
两种方法反转单链表
查看>>
二叉树递归前序、中序、后序遍历
查看>>
在VIEW中加载UICollectionView
查看>>
散列桶
查看>>
eclipse修改 服务器默认路径
查看>>
[iOS Animation]-CALayer 视觉效果
查看>>