标签:using class out cout cin ret add iostream include
模板题
#include <iostream>
#include <cstdio>
using namespace std;
struct Edge{
int too, nxt;
}edge[200005];
int n, m, dfn[100005], loo[100005], ind, uu, vv, cnt, hea[100005];
bool isa[100005];
void add_edge(int fro, int too){
edge[++cnt].nxt = hea[fro];
edge[cnt].too = too;
hea[fro] = cnt;
}
void tarjan(int u, int f){
dfn[u] = loo[u] = ++ind;
int cd=0;
for(int i=hea[u]; i; i=edge[i].nxt){
int t=edge[i].too;
if(!dfn[t]){
cd++;
tarjan(t, u);
loo[u] = min(loo[u], loo[t]);
if(f!=-233 && loo[t]>=dfn[u]) isa[u] = true;
}
loo[u] = min(loo[u], dfn[t]);
}
if(f<0 && cd>=2) isa[u] = true;
}
int main(){
cin>>n>>m;
for(int i=1; i<=m; i++){
scanf("%d %d", &uu, &vv);
add_edge(uu, vv);
add_edge(vv, uu);
}
for(int i=1; i<=n; i++)
if(!dfn[i])
tarjan(i, -233);
int ans=0;
for(int i=1; i<=n; i++)
if(isa[i])
ans++;
cout<<ans<<endl;
for(int i=1; i<=n; i++)
if(isa[i])
printf("%d ", i);
return 0;
}
标签:using class out cout cin ret add iostream include
原文地址:http://www.cnblogs.com/poorpool/p/7976062.html