Submission #948551

#TimeUsernameProblemLanguageResultExecution timeMemory
948551huyboyPipes (CEOI15_pipes)C++17
20 / 100
97 ms16272 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; const short N = 5000; vector<pair<short,int>> g[N]; vector<short> tin(N), low(N); void dfs(short v, short p, vector<bool>& vis, short& timer) { vis[v] = true; tin[v] = low[v] = timer++; for (auto [to, check] : g[v]) { if (check == p) continue; if(vis[to]){ low[v] = min(low[v], low[to]); } else{ dfs(to, check, vis, timer); low[v] = min(low[v], low[to]); if (low[to] > tin[v]) cout << v << " " << to << "\n"; } } } void solve(){ short n; int m; cin >> n >> m; for(int i = 0; i < m; i++){ short a, b; cin >> a >> b; g[a].emplace_back(b, i); g[b].emplace_back(a, i); } vector<bool> vis(n, false); short timer = 0; for(short i = 0; i < n; i++){ if(!vis[i]){ dfs(i, -1, vis, timer); } } } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int t = 1; // cin >> t; while(t--){ solve(); } 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...