#include <bits/stdc++.h>
using namespace std;
int n, m, root, sum;
int first[9], next[25], u[25], v[25];
int num[9], low[9], flag[9], indexs;
void add(int x, int y)
{
u[sum] = x, v[sum] = y;
next[sum] = first[x];
first[x] = sum;
sum++;
}
void dfs(int cur, int father)
{
int child = 0, k;
indexs++;
num[cur] = indexs;
low[cur] = indexs;
k = first[cur];
while(k != -1)
{
if(num[v[k]] == 0)
{
child++;
dfs(v[k], cur);
low[cur] = min(low[cur], low[v[k]]);
if(cur != root && low[v[k]] >= num[cur])
flag[cur] = 1;
if(cur == root && child == 2)
flag[cur] = 1;
}
else if(v[k] != father)
{
low[cur] = min(low[cur], num[v[k]]);
}
k = next[k];
}
return ;
}
int main()
{
int i, x, y;
scanf("%d %d", &n, &m);
for(i = 1; i <= n; i++)
first[i] = -1;
for(i = 1; i <= m; i++)
{
scanf("%d %d", &x, &y);
add(x, y);
add(y, x);
}
root = 1;
dfs(1, root);
for(i = 1; i <= n; i++)
if(flag[i])
cout << i << endl;
return 0;
}
求图的割点
最新推荐文章于 2023-09-23 13:38:00 发布