Submission #555408

#TimeUsernameProblemLanguageResultExecution timeMemory
555408hidden1Pipes (CEOI15_pipes)C++14
20 / 100
967 ms65536 KiB
#include <bits/stdc++.h> using namespace std; //#pragma GCC optimize ("O3") //#pragma GCC target ("sse4") #ifndef LOCAL #define cerr if(false) cerr #endif #define endl "\n" #define out(x) "[" << #x << "=" << x << "]" struct debug { debug() { cerr << "DEBUGGER: " << endl; } ~debug() { cerr << endl << "DEBUGGER_END " << endl; } template<class T> debug& operator <<(const T x) { cerr << x << " "; return *this; } }; template<class T> inline ostream &operator <<(ostream &out, const vector<T> &x) { for(const auto &it : x) { out << it << " "; } return out; } template<class T, class T2> inline ostream &operator <<(ostream &out, const pair<T, T2> &x) { return out << x.first << " " << x.second; } template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; } template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; } typedef long long ll; const ll mod = 1e9 + 7; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// const int MAX_N = 1e5 + 10; vector<pair<int, int> > g[MAX_N]; int low[MAX_N], in[MAX_N], tme = 0; int n, m; void dfs(int x, int ind) { in[x] = low[x] = ++ tme; for(auto it : g[x]) { if(low[it.first] == 0) { dfs(it.first, it.second); chkmin(low[x], low[it.first]); if(low[it.first] > in[x]) { cout << x << " " << it.first << endl; } } else if(it.second != ind) { chkmin(low[x], in[it.first]); } } } signed main() { #ifndef LOCAL ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #endif cin >> n >> m; for(int i = 0; i < m; i ++) { int a, b; cin >> a >> b; g[a].push_back({b, i}); g[b].push_back({a, i}); } for(int i = 1; i <= n; i ++) { if(low[i] == 0) { 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...