#include <bits/stdc++.h>
using namespace std;
#define ll int
#define ii pair<ll,ll>
#define endl '\n'
const ll mod=1e9+7;
const ll maxn=1e5+5;
set<ii> s;
vector<ll> adj[maxn];
ll vis[maxn][2];
ll 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] && s.find(make_pair(u,a))==s.end()){
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);
}
for (int i=1;i<=n;i++){
sort(adj[i].begin(),adj[i].end());
for (int j=0;j<max<int>(0,adj[i].size()-1);j++){
if (adj[i][j]==adj[i][j+1]){
s.emplace(i,adj[i][j]);
}
}
}
for (int i=1;i<=n;i++){
if (vis[i][1]!=-1) continue;
cnt=0;
dfs(i,-1);
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2636 KB |
Wrong number of edges |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
2892 KB |
Wrong number of edges |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
156 ms |
12332 KB |
Output is correct |
2 |
Runtime error |
215 ms |
21932 KB |
Memory limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
252 ms |
13428 KB |
Output is correct |
2 |
Runtime error |
323 ms |
25680 KB |
Memory limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
503 ms |
22852 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
664 ms |
24568 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1171 ms |
45120 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1545 ms |
57448 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2053 ms |
58828 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1866 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |