#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> rednibr(200,0);
vector<int> artocki;
vector<vector<int> > v;
int broj=0;
int dfs(int x,int pr,int broj)
{
int minbr=broj;
int granki=0;
int t;
int maxi=0;
rednibr[x]=broj;
for(int i=0;i<v[x].size();i++)
{
if(v[x][i]==pr)
continue;
if(rednibr[v[x][i]])
minbr=min(minbr,rednibr[v[x][i]]);
else
{
int t=dfs(v[x][i],x,broj+1);
minbr=min(minbr,t);
maxi=max(maxi,t);
granki++;
}
}
if(x==0)
{
if(granki>1)
artocki.push_back(x);
}
else
{
if(maxi>=rednibr[x])
artocki.push_back(x);
}
return minbr;
}
int main()
{
int n;
cin>>n;
int m;
cin>>m;
vector<int> vec;
vector<int> s,e;
v.insert(v.begin(),n+m+4,vec);
int nov=m;
for(int i=0;i<m;i++)
{
int a,b;
cin>>a>>b;
a--;
b--;
s.push_back(a);
e.push_back(b);
v[a].push_back(nov);
v[b].push_back(nov);
v[nov].push_back(a);
v[nov].push_back(b);
nov++;
}
dfs(0,-1,1);
sort(artocki.begin(),artocki.end());
for(int i=0;i<artocki.size();i++)
{
if(artocki[i]>=m)
cout<<s[artocki[i]-m]+1<<" "<<e[artocki[i]-m]+1<<endl;
}
cout<<endl;
return 0;
}
/*
9 11
1 2
2 3
3 1
3 4
4 5
5 6
6 4
6 7
7 8
8 9
9 7
*/
Compilation message
pipes.cpp: In function 'int dfs(int, int, int)':
pipes.cpp:16:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<v[x].size();i++)
~^~~~~~~~~~~~
pipes.cpp:13:9: warning: unused variable 't' [-Wunused-variable]
int t;
^
pipes.cpp: In function 'int main()':
pipes.cpp:68:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<artocki.size();i++)
~^~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
384 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
7 ms |
1792 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
34 ms |
29304 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
56 ms |
49504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
101 ms |
65536 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
177 ms |
65536 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
55 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 |
60 ms |
65536 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |