# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
948413 |
2024-03-18T05:31:14 Z |
vjudge1 |
Pipes (CEOI15_pipes) |
C++17 |
|
87 ms |
16268 KB |
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define all(x) x.begin(), x.end()
#define size(x) (int)x.size()
const short N = 5000;
vector<pair<short, int>> g[N];
bool vis[N];
int tin[N], fup[N], timer;
vector<pair<short, short>> bridges;
void dfs(short v, short p = -1, int idx = -1) {
vis[v] = true;
tin[v] = fup[v] = ++timer;
for (auto [to, new_idx] : g[v]) {
if (idx == new_idx) continue;
else if (vis[to]) fup[v] = min(fup[v], tin[to]);
else {
dfs(to, v, new_idx);
fup[v] = min(fup[v], fup[to]);
if (fup[to] > tin[v]) {
bridges.push_back({v, to});
}
}
}
}
signed main() {
cin.tie(nullptr)->sync_with_stdio(false);
short n; int m;
cin >> n >> m;
for (int i = 0; i < m; ++i) {
short a, b; cin >> a >> b;
a--, b--;
g[a].push_back({b, i});
g[b].push_back({a, i});
}
for (short i = 0; i < n; ++i) {
if (!vis[i]) dfs(i);
}
for (auto [a, b] : bridges) {
cout << a + 1 << ' ' << b + 1 << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1116 KB |
Output is correct |
2 |
Correct |
3 ms |
860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
87 ms |
16268 KB |
Output is correct |
2 |
Correct |
85 ms |
15388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
860 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
860 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
860 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
860 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
860 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |