Submission #388515

#TimeUsernameProblemLanguageResultExecution timeMemory
388515armanmohammadiPipes (CEOI15_pipes)C++11
100 / 100
1333 ms12764 KiB
/* _________ .---""" """---. :______.-': : .--------------. : | ______ | | : : | |:______B:| | | Little Error: | | |:______B:| | | | | |:______B:| | | Power not | | | | | | found. | | |:_____: | | | | | | == | | : : | | O | : '--------------' : | o | :'---...______...---' | o |-._.-i___/' \._ |'-.____o_| '-. '-...______...-' `-._ :_________: `.____________________ `-.___.-. .'.eeeeeeeeeeeeeeeeee.'. :___: fsc .'.eeeeeeeeeeeeeeeeeeeeee.'. :____________________________: */ //in the name of god //if you read this code please search about imam hussain #include<bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back #define endl "\n" #define X first #define Y second #define pii pair<int,int> #define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0) #define read freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout) const int maxn=1e5+5; const int mod=1e9+7; const int inf=1e9; const int del=728729; ll poww(ll a, ll b, ll md) {return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));} int par[maxn][2] ; int mark[maxn] ; int an; vector<int>adj[maxn]; int n ; int m ; int getPar(int v){ if(par[v][an] == v){ return v ; }else return par[v][an] = getPar(par[v][an]); } bool merge(int u, int v){ u = getPar(u); v = getPar(v); if (u == v){ return false; } par[u][an] = v; return true; } void dfs(int v, int p = 0){ mark[v] = 1; par[v][1] = maxn; int cnt = 0 ; for (int u : adj[v]){ if (u == p){ cnt ++; continue; } if (mark[u]){ par[v][1] = min(par[v][1], par[u][0]); } else{ par[u][0] = par[v][0] + 1; dfs(u, v); par[v][1] = min(par[v][1], par[u][1]); } } if (p and cnt == 1 and par[p][0] < par[v][1]){ cout << p << " " << v << endl; } } int main(){ migmig ; cin >> n >> m; for (int i = 0; i < maxn; i ++){ par[i][0] = par[i][1] = i; } for (int i = 0; i < m; i ++){ int u ; int v ; bool flag = true; cin >> u >> v; an = 0; if (merge(u, v)){ adj[u].pb(v); adj[v].pb(u); flag = 0; } an = 1; if (flag and merge(u, v)){ adj[u].pb(v); adj[v].pb(u); } }memset(par, 0, sizeof par); for (int v = 1; v <= n; v ++){ if (!mark[v]){ dfs(v); } } 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...