#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
int n,m;
vector<vector<short>> muchii;
bool use[100005];
int topar[100005],par[100005];
int niv[100005],nivmin[100005];
void dfs(int nod)
{
use[nod]=1;
nivmin[nod]=niv[nod];
for(int i:muchii[nod])
{
int node=i;
if(node==par[nod])
continue;
if(!use[node])
{
par[node]=nod;
niv[node]=niv[nod]+1;
dfs(node);
nivmin[nod]=min(nivmin[nod],nivmin[node]);
}
else
nivmin[nod]=min(nivmin[nod],niv[node]);
}
int cnt=0;
if(nivmin[nod]==niv[nod]&&par[nod]!=0)
{
for(int i:muchii[nod])
if(i==par[nod])
cnt++;
if(cnt==1)
cout<<par[nod]<<' '<<nod<<'\n';
}
}
int main()
{
cin>>n>>m;
muchii.resize(n+1);
for(int i=1;i<=m;i++)
{
int a,b;
cin>>a>>b;
muchii[a].push_back(b);
muchii[b].push_back(a);
}
for(int i=1;i<=n;i++)
sort(muchii[i].begin(),muchii[i].end());
for(int i=1;i<=n;i++)
if(!use[i])
{
niv[i]=1;
dfs(i);
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
852 KB |
Output is correct |
2 |
Correct |
7 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
350 ms |
4700 KB |
Output is correct |
2 |
Correct |
306 ms |
4208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
545 ms |
6988 KB |
Output is correct |
2 |
Correct |
722 ms |
8816 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
920 ms |
13712 KB |
Output is correct |
2 |
Correct |
797 ms |
12092 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1202 ms |
27624 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2053 ms |
49224 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2781 ms |
65536 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3579 ms |
65536 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4573 ms |
65536 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |