#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int v, e, ID = 0;
int num[MAXN], low[MAXN];
int p[2][MAXN], r[2][MAXN];
vector<int> adj[MAXN];
int root(int id, int x){
if(p[id][x] == x) return x;
return p[id][x] = root(id, p[id][x]);
}
void connect(int id, int x, int y){
x = root(id, x), y = root(id, y);
if(r[id][x] > r[id][y]) swap(x, y);
p[id][x] = y; r[id][y] ++;
}
bool connected(int id, int x, int y){
x = root(id, x), y = root(id, y);
return x == y;
}
void dfs(int u, int par){
num[u] = low[u] = ID ++;
for(int v : adj[u]){
if(num[v] == -1){
dfs(v, u);
if(num[u] < low[v])
cout << u+1 << ' ' << v+1 << '\n';
low[u] = min(low[u], low[v]);
} else if(v != par){
low[u] = min(low[u], num[v]);
} else par = -1;
}
}
void dfs(int x, int par){
num[x] = low[x] = ID ++;
for(int nxt : adj[x]){
if(num[nxt] == -1){
dfs(nxt, x);
if(num[x] < low[nxt])
cout << x+1 << ' ' << nxt+1 << '\n';
low[x] = min(low[x], low[nxt]);
} else if(nxt != par){
low[x] = min(low[x], num[nxt]);
} else par = -1;
}
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin >> v >> e;
for(int i = 0; i < v; i ++)
p[0][i] = p[1][i] = i,
r[0][i] = r[1][i] = 0,
num[i] = low[i] = -1;
for(int i = 0; i < e; i ++){
int a, b; cin >> a >> b;
if(!connected(0, a-1, b-1)){
adj[a-1].push_back(b-1);
adj[b-1].push_back(a-1);
connect(0, a-1, b-1);
} else if(!connected(1, a-1, b-1)){
adj[a-1].push_back(b-1);
adj[b-1].push_back(a-1);
connect(1, a-1, b-1);
}
}
for(int i = 0; i < v; i ++)
if(num[i] == -1)
dfs(i, -1);
}
Compilation message
pipes.cpp:37:6: error: redefinition of 'void dfs(int, int)'
37 | void dfs(int x, int par){
| ^~~
pipes.cpp:24:6: note: 'void dfs(int, int)' previously defined here
24 | void dfs(int u, int par){
| ^~~