在无向图中,去掉了i号边,连通块数量增加了,那么i号边就是桥。
#include<bits/stdc++.h>
using namespace std;
#define ls rt<<1
#define rs (rt<<1)+1
#define PI acos(-1)
#define eps 1e-8
#define ll long long
#define fuck(x) cout<<#x<<" "<<x<<endl;
typedef pair<int,int> pii;
const int inf=2e9;
const int maxn=1e6+10;
int d[4][2]={1,0,-1,0,0,1,0,-1};
//int lowbit(int x){return x&-x;}
//void add(int x,int v){while(x<=n)bit[x]+=v,x+=lowbit(x);}
//int sum(int x){int ans=0;while(x>=1) ans+=bit[x],x-=lowbit(x);return ans;}
inline ll read() {
ll s = 0,w = 1;
char ch = getchar();
while(!isdigit(ch)) {
if(ch == '-') w = -1;
ch = getchar();
}
while(isdigit(ch))
s = s * 10 + ch - '0',ch = getchar();
return s * w;
}
inline void write(ll x) {
if(x < 0)
putchar('-'), x = -x;
if(x > 9)
write(x / 10);
putchar(x % 10 + '0');
}
int gcd(int x,int y){
return y==0?x:gcd(y,x%y);
}
struct edge{
int u,v,nxt;
}e[maxn<<1];
int head[maxn],dfn[maxn],low[maxn],cnt,n,m;
vector<int>bri;
void dfs(int now,int fa){
bool flag=0;
dfn[now]=low[now]=++cnt;
for(int i=head[now];i!=-1;i=e[i].nxt){
int v=e[i].v;
if(!dfn[v]){
dfs(v,now);
low[now]=min(low[now],low[v]);
if(low[v]>dfn[now]){
bri.push_back(i);
}
}
else
if(v!=fa||flag)
low[now]=min(low[now],dfn[v]);
else
flag=1;
}
}
int main(){
return 0;
}
一个边双连通分量里任意两点有至少两条边不重复路径,即没有桥
#include<bits/stdc++.h>
using namespace std;
#define ls rt<<1
#define rs (rt<<1)+1
#define PI acos(-1)
#define eps 1e-8
#define ll long long
#define fuck(x) cout<<#x<<" "<<x<<endl;
typedef pair<int,int> pii;
const int inf=2e9;
const int maxn=1e6+10;
int d[4][2]={1,0,-1,0,0,1,0,-1};
//int lowbit(int x){return x&-x;}
//void add(int x,int v){while(x<=n)bit[x]+=v,x+=lowbit(x);}
//int sum(int x){int ans=0;while(x>=1) ans+=bit[x],x-=lowbit(x);return ans;}
inline ll read() {
ll s = 0,w = 1;
char ch = getchar();
while(!isdigit(ch)) {
if(ch == '-') w = -1;
ch = getchar();
}
while(isdigit(ch))
s = s * 10 + ch - '0',ch = getchar();
return s * w;
}
inline void write(ll x) {
if(x < 0)
putchar('-'), x = -x;
if(x > 9)
write(x / 10);
putchar(x % 10 + '0');
}
int gcd(int x,int y){
return y==0?x:gcd(y,x%y);
}
struct edge{
int u,v,nxt;
}e[maxn<<1];
int head[maxn],dfn[maxn],low[maxn],bcc[maxn],bccn,cnt,n,m;
vector<int>bri;
stack<int>sta;
void dfs(int now,int fa){
bool flag=0;//flag用于处理重边的情况
dfn[now]=low[now]=++cnt;
sta.push(now);
for(int i=head[now];i!=-1;i=e[i].nxt){
int v=e[i].v;
if(!dfn[v]){
dfs(v,now);
low[now]=min(low[now],low[v]);
}
else
if(v!=fa||flag)
low[now]=min(low[now],dfn[v]);
else
flag=1;
}
if(low[now]==dfn[now]){
bccn++;
for(;;){
int tmp=sta.top();sta.pop();
bcc[tmp]=bccn;
if(tmp==now) break;
}
}
}
int main(){
return 0;
}