# include <stdio.h>
# include <bits/stdc++.h>
#define Accepted 0
#define pb push_back
#define F first
#define S second
#define For(i,x,y) for (int i = x; i <= y; i ++)
#define FOr(i,x,y) for (int i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;
int n, m;
bitset < 100101 > g[100101];
vector < pair < int, int > > ans;
int tin[100101];
int fup[100101];
int timer;
inline void dfs (int v, int par = 0) {
tin[v] = fup[v] = ++ timer;
for (int i = g[v]._Find_first(); i < g[v].size(); i = g[v]._Find_next(i)) {
if (i == par) continue;
if (tin[i]) {
fup[v] = min(fup[v], tin[i]);
} else {
dfs (i, v);
fup[v] = min(fup[v], fup[i]);
if (tin[v] < fup[i]) {
ans.pb({min(v, i), max(v, i)});
}
}
}
}
int main () {
cin >> n >> m;
For (i, 1, m) {
int l, r;
cin >> l >> r;
g[l][r] = 1;
g[r][l] = 1;
}
For (i, 1, n) {
if (!tin[i]) {
dfs (i);
}
}
sort(ans.begin(), ans.end());
ans.resize(unique(ans.begin(), ans.end()) - ans.begin());
for (auto it : ans)
cout << it.F << ' ' << it.S << '\n';
return Accepted;
}
Compilation message
pipes.cpp: In function 'void dfs(int, int)':
pipes.cpp:24:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = g[v]._Find_first(); i < g[v].size(); i = g[v]._Find_next(i)) {
~~^~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
640 KB |
Output is correct |
2 |
Incorrect |
2 ms |
640 KB |
Wrong number of edges |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
36 ms |
20264 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 |
391 ms |
16392 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 |
774 ms |
50496 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 |
64 ms |
65536 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
59 ms |
65536 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
59 ms |
65536 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
75 ms |
65536 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
58 ms |
65536 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
61 ms |
65536 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |