// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define pb push_back
template<class T> using V = vector<T>;
const int nax = 1e5+5;
struct DSU {
int e[nax]; void init() { memset(e, -1, sizeof e); };
int get(int x) { return e[x] < 0 ? x : e[x] = get(e[x]); }
bool unite(int x, int y) {
x = get(x), y = get(y); if (x == y) return 0;
if (e[x] > e[y]) swap(x, y);
e[x] += e[y]; e[y] = x; return 1;
}
};
V<int> adj[nax];
int low[nax], disc[nax], t = 0;
bitset<nax> vis;
V<array<int, 2>> ans;
void dfs(int u, int p = -1) {
vis[u] = 1;
disc[u] = low[u] = t++;
bool twi = 0;
for(auto &v : adj[u]) if (v != p || twi) {
if (vis[v]) low[u] = min(low[u], disc[v]);
else {
dfs(v, u);
low[u] = min(low[u], low[v]);
// cout << u << " " << low[u] << " " << disc[v] << endl;
if (low[v] > disc[u]) {
cout << u + 1 << " " << v + 1 << endl;
}
}
} else twi = 1;
}
int main() {
cin.tie(0)->sync_with_stdio(0);
memset(low, -1, sizeof low);
memset(disc, -1, sizeof disc);
vis.reset();
int N, M; cin >> N >> M;
DSU F, S; F.init(), S.init();
int u, v;
for(int e = 0; e < M; e++) {
cin >> u >> v; --u, --v;
if (F.unite(u, v) || S.unite(u, v)) {
// cout << u << " " << v << endl;
adj[u].pb(v);
adj[v].pb(u);
}
}
for(int i = 0; i < N; i++) if (!vis[i]) dfs(i);
return 0;
Compilation message
pipes.cpp: In function 'int main()':
pipes.cpp:69:13: error: expected '}' at end of input
69 | return 0;
| ^
pipes.cpp:47:12: note: to match this '{'
47 | int main() {
| ^