# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
527242 |
2022-02-17T04:09:45 Z |
siewjh |
Pipes (CEOI15_pipes) |
C++17 |
|
1507 ms |
65540 KB |
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <set>
using namespace std;
const int MAXN = 100'005;
vector<int> adjlist[MAXN];
int tvis[MAXN], lo[MAXN];
int cnt = 0;
set<pair<int, int>> ans;
void dfs(int x, int par) {
tvis[x] = lo[x] = cnt++;
for (auto nxt : adjlist[x]) {
if (nxt == par) continue;
if (tvis[nxt] != INT_MAX) lo[x] = min(lo[x], tvis[nxt]);
else {
dfs(nxt, x);
lo[x] = min(lo[x], lo[nxt]);
if (lo[nxt] > tvis[x]) ans.insert({ min(nxt, x), max(nxt, x) });
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int nodes, edges; cin >> nodes >> edges;
set<pair<int, int>> elist, mult;
for (int i = 0; i < edges; i++) {
int a, b; cin >> a >> b;
if (a > b) swap(a, b);
adjlist[a].push_back(b);
adjlist[b].push_back(a);
if (elist.count({ a, b })) mult.insert({ a, b });
elist.insert({ a, b });
}
for (int i = 1; i <= nodes; i++) tvis[i] = INT_MAX;
for (int i = 1; i <= nodes; i++)
if (tvis[i] == INT_MAX)
dfs(i, -1);
for (auto x : ans)
if (!mult.count(x))
cout << x.first << ' ' << x.second << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
2 ms |
2636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
3660 KB |
Output is correct |
2 |
Correct |
8 ms |
3404 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
846 ms |
38640 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1507 ms |
61368 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1384 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1414 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1408 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1452 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1381 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1502 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |