#include <bits/stdc++.h>
using namespace std;
#define ll int
#define ii pair<ll,ll>
#define endl '\n'
const ll inf=1e15;
const ll mod=1e9+7;
const ll maxn=1e5+5;
vector<ll> adj[maxn];
ll vis[maxn][2];
ll dfsRoot,cnt;
void dfs(ll a, ll p){
vis[a][0]=vis[a][1]=cnt++;
for (auto &u:adj[a]){
if (vis[u][1]!=-1){
if (u!=p){
vis[a][0]=min(vis[u][1],vis[a][0]);
}
continue;
}
dfs(u,a);
if (vis[u][0]>vis[a][1]){
cout<<a<<' '<<u<<endl;
}
vis[a][0]=min(vis[u][0],vis[a][0]);
}
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n,e,a,b;
cin>>n>>e;
for (int i=0;i<e;i++){
cin>>a>>b;
adj[a].emplace_back(b);
adj[b].emplace_back(a);
}
memset(vis,-1,sizeof(vis));
for (int i=1;i<=n;i++){
if (vis[i][1]!=-1) continue;
dfsRoot=i;
cnt=0;
dfs(i,-1);
}
return 0;
}
Compilation message
pipes.cpp:7:14: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+15' to '2147483647' [-Woverflow]
7 | const ll inf=1e15;
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3404 KB |
Output is correct |
2 |
Incorrect |
2 ms |
3404 KB |
Wrong number of edges |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
3916 KB |
Output is correct |
2 |
Incorrect |
5 ms |
3660 KB |
Wrong number of edges |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
108 ms |
11596 KB |
Output is correct |
2 |
Correct |
101 ms |
10916 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
180 ms |
15004 KB |
Output is correct |
2 |
Runtime error |
211 ms |
19292 KB |
Memory limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
345 ms |
25772 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
563 ms |
31560 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
907 ms |
53300 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1245 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1539 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1667 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |