#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, m, cnt, timer, fup[N], used[N], tin[N];
vector < int > g[N];
vector < pair < int, int > > ans;
inline void dfs(int v, int p = -1) {
used[v] = 1;
tin[v] = ++timer;
fup[v] = timer;
for (int to : g[v]) {
if (to == p)
continue;
if (used[to])
fup[v] = min(fup[v], tin[to]);
else {
dfs(to, v);
fup[v] = min(fup[v], fup[to]);
if (fup[to] > tin[v])
ans.push_back({v, to});
}
}
}
int main() {
cin >> n >> m;
for (int i = 1; i <= m; ++i) {
int v, u;
cin >> v >> u;
g[v].push_back(u);
g[u].push_back(v);
}
for (int i = 1; i <= n; ++i) {
if (!used[i]) {
dfs(i);
}
}
for (int i = 0; i < ans.size(); ++i) {
cout << ans[i].first << " " << ans[i].second << (i + 1 == ans.size() ? "" : "\n");
}
}
Compilation message
pipes.cpp: In function 'int main()':
pipes.cpp:43:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < ans.size(); ++i) {
~~^~~~~~~~~~~~
pipes.cpp:44:64: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
cout << ans[i].first << " " << ans[i].second << (i + 1 == ans.size() ? "" : "\n");
~~~~~~^~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
2688 KB |
Output is correct |
2 |
Incorrect |
4 ms |
2688 KB |
Wrong number of edges |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
3072 KB |
Output is correct |
2 |
Incorrect |
11 ms |
2944 KB |
Wrong number of edges |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
330 ms |
10652 KB |
Output is correct |
2 |
Correct |
322 ms |
10136 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
616 ms |
14040 KB |
Output is correct |
2 |
Runtime error |
755 ms |
18556 KB |
Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1159 ms |
24644 KB |
Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1966 ms |
29540 KB |
Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2925 ms |
51132 KB |
Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4046 ms |
64608 KB |
Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4894 ms |
65536 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5013 ms |
58016 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |