博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ZOJ 2588 Burning Bridges(无向连通图求割边)
阅读量:4326 次
发布时间:2019-06-06

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

题目地址:

由于数组开小了而TLE了。。这题就是一个求无向连通图最小割边。仅仅要推断dfn[u]是否<low[v],由于low指的当前所能回到的祖先的最小标号,增加low[v]大于dfn[u]时,说明v无法通过其它边回到u之前的点。也就是说v假设想要回到u的祖先点。必需要经过u点,那这条边非常明显就是一条割边。这题还要去重边,假如有重边的话。说明怎么销毁哪条边总能通过还有一条边,所以仅仅要有重边。说明这两点之间没有割边。

代码例如以下;

#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;int head[20020], cnt, index1, ans;int low[20103], dfn[20103], road[20103];struct node{ int num, u, v, next, tag;} edge[220000];void add(int num, int u, int v){ int i; for(i=head[u]; i!=-1; i=edge[i].next) { if(edge[i].v==v) break; } if(i!=-1) { edge[i].tag=1; return ; } edge[cnt].tag=0; edge[cnt].num=num; edge[cnt].v=v; edge[cnt].next=head[u]; head[u]=cnt++;}void tarjan(int u, int fa){ low[u]=dfn[u]=++index1; for(int i=head[u]; i!=-1; i=edge[i].next) { int v=edge[i].v; if(v==fa) continue ; if(!dfn[v]) { tarjan(v,u); low[u]=min(low[u],low[v]); if(dfn[u]

转载于:https://www.cnblogs.com/claireyuancy/p/6991980.html

你可能感兴趣的文章
mac下多线程实现处理
查看>>
C++ ifstream ofstream
查看>>
跟初学者学习IbatisNet第四篇
查看>>
seL4环境配置
查看>>
Git报错:insufficient permission for adding an object to repository database .git/objects
查看>>
ajax跨域,携带cookie
查看>>
BZOJ 1600: [Usaco2008 Oct]建造栅栏( dp )
查看>>
洛谷 CF937A Olympiad
查看>>
Codeforces Round #445 C. Petya and Catacombs【思维/题意】
查看>>
用MATLAB同时作多幅图
查看>>
python中map的排序以及取出map中取最大最小值
查看>>
ROR 第一章 从零到部署--第一个程序
查看>>
<form>标签
查看>>
vue去掉地址栏# 方法
查看>>
Lambda03 方法引用、类型判断、变量引用
查看>>
was集群下基于接口分布式架构和开发经验谈
查看>>
MySQL学习——MySQL数据库概述与基础
查看>>
ES索引模板
查看>>
HDU2112 HDU Today 最短路+字符串哈希
查看>>
JPanel重绘
查看>>