제출 #580251

#제출 시각아이디문제언어결과실행 시간메모리
580251MODDIPipes (CEOI15_pipes)C++14
10 / 100
1866 ms65536 KiB
#include <bits/stdc++.h> #define ll long long #define pii pair<int,int> #define pll pair<ll,ll> #define vi vector<int> #define vl vector<ll> #define mp make_pair #define pb push_back using namespace std; int n, m; vector<int> G[100100]; vector<bool> visited; vector<int> tin, low; int timer; void IS_BRIDGE(int a, int b){ cout<<a+1<<" "<<b+1<<endl; } void dfs(int v, int p = -1) { visited[v] = true; tin[v] = low[v] = timer++; for (int to : G[v]) { if (to == p) continue; if (visited[to]) { low[v] = min(low[v], tin[to]); } else { dfs(to, v); low[v] = min(low[v], low[to]); if (low[to] > tin[v]) IS_BRIDGE(v, to); } } } void init() { timer = 0; visited.assign(n, false); tin.assign(n, -1); low.assign(n, -1); for (int i = 0; i < n; ++i) { if (!visited[i]) dfs(i); } } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n>>m; for(int i = 0; i < m; i++){ int a, b; cin>>a>>b; a--; b--; G[a].pb(b); G[b].pb(a); } init(); }
#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...