Submission #1278637

#TimeUsernameProblemLanguageResultExecution timeMemory
1278637g4yuhgPipes (CEOI15_pipes)C++20
30 / 100
1705 ms131072 KiB
//Huyduocdithitp
#include<bits/stdc++.h>
typedef int ll;
#define endl '\n'
#define fi first
#define se second
#define pii pair<ll,ll>
#define N 100005
#define LOG 18
using namespace std;

const ll inf = 1e9;

bool ghuy4g;

ll n, m;
vector<pii> adj[N];
ll num[N], low[N], timeDfs;

void dfs(ll u, ll parent) {
	//cout <<u << " | " << parent << endl;
	num[u] = low[u] = ++ timeDfs;
	for (auto v : adj[u]) {
		if (v.se == parent) continue;
		if (num[v.fi]) {
			low[u] = min(low[u], num[v.fi]);
		}
		else {
			dfs(v.fi, v.se);
			low[u] = min(low[u], low[v.fi]);
			if (low[v.fi] == num[v.fi]) {
				cout << u << " " << v.fi << endl;
			}
		}
	}
}

void solve() {
	for (int i = 1; i <= n; i ++) {
		if (num[i] == 0) {
			dfs(i, 0);
		}
	}
}

bool klinh;

signed main() {
	//freopen("test.inp", "r", stdin);
	//freopen("test.out", "w", stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	for (int i = 1; i <= m; i ++) {
		ll u, v;
		cin >> u >> v;
		adj[u].push_back({v, i});
		adj[v].push_back({u, i});
	}
	
	solve();
	
	cerr << fabs(&klinh - &ghuy4g) / double(1024 * 1024);
	
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...