Submission #527268

#TimeUsernameProblemLanguageResultExecution timeMemory
527268ecxxPipes (CEOI15_pipes)C++17
10 / 100
2843 ms65540 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; int* depth = new int[MAXN]{0}; int* low = new int[MAXN]{0}; int* pos = new int[MAXN]; int* edgelist; void AP(int i, int d, int pa) { depth[i] = d; low[i] = d; int paedges = 0; for (int k = pos[i]; k < pos[i+1]; k++) { int ch = edgelist[k]; //cout << i << " " << ch << " " << pa << " p" << endl; if (ch==pa) { paedges++; continue; } if (depth[ch] != -1) { low[i] = min(low[i], depth[ch]); } else { AP(ch, d+1, i); low[i] = min(low[i], low[ch]); } } //cout << i << " " << pa << " " << paedges << endl; if (pa==-1) return; if (low[i] > depth[pa] && paedges < 2) { cout << i+1 << " " << pa+1 << "\n"; } } int main() { int N, M, a, b; cin >> N >> M; vector<pair<int, int> > EL(2*M, {0, 0}); for (int i = 0; i < M; i++) { cin >> a >> b; a--;b--; EL[2*i] = {a,b}; EL[2*i+1] = {b,a}; } sort(EL.begin(), EL.end()); int curri = -1; int q = 0; edgelist = new int[2*M+5]; for (auto a : EL) { if (a.first != curri) { pos[a.first] = q; curri = a.first; } edgelist[q] = a.second; q++; } pos[curri+1] = q; EL.clear();EL.shrink_to_fit(); for (int i = 0; i < N; i++) { depth[i] = -1; } for (int i = 0; i < N; i++) { if (depth[i] == -1) AP(i,0,-1); } }
#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...