Submission #364815

#TimeUsernameProblemLanguageResultExecution timeMemory
364815knightron0Pipes (CEOI15_pipes)C++14
10 / 100
316 ms21888 KiB
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define fr first #define sc second #define clr(a) memset(a, 0, sizeof(a)) #define sz(x) x.size() #define printarray(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout<<*it<<" "; cout<<endl; #define rep(n) for (ll i = 0; i < n; i++) #define repc(i, n) for (ll i = 0; i < n; i++) #define FOR(i, x, y) for (int i = x; i < y; i++) #define DEC(i, x, y) for (int i = x; i >= y; i--) #define all(v) v.begin(), v.end() #define min3(a, b, c) min(a, min(b, c)) #define max3(a, b, c) max(a, max(b, c)) #define alla(a, n) a, a + n #define gcd(a, b) __gcd(a, b) #define lcm(a, b) (a * b)/gcd(a, b) #define ull unsigned long long using namespace std; const int MOD = 1e9 + 7; const int MAXN = 1e4 + 5; vector<int> adj[MAXN]; bool vis[MAXN]; int timer = 0; int tin[MAXN], low[MAXN]; void dfs(int u, int p){ vis[u] = true; timer++; tin[u] = low[u] = timer; for(int v: adj[u]){ if(v == p) continue; if(vis[v]){ low[u] = min(low[u], tin[v]); } else { dfs(v, u); low[u] = min(low[u], low[v]); if (low[v] > tin[u]) { cout<<u<<' '<<v<<endl; } } } } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m; cin>>n>>m; for(int i= 0;i<m;i++){ int t1, t2; cin>>t1>>t2; adj[t1].pb(t2); adj[t2].pb(t1); } timer = 0; memset(low, -1, sizeof(low)); memset(tin, -1, sizeof(tin)); clr(vis); for(int i= 1;i<=n;i++){ if(!vis[i]){ dfs(i, -1); } } 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...