标签:next lag \n std ace iostream efi fine names
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #define M 100010 5 using namespace std; 6 struct point{ 7 int to,next; 8 }e[M<<1]; 9 int n,m,num,cnt,root,tot; 10 int head[M],cut[M],dfn[M],low[M]; 11 void add(int from,int to) 12 { 13 e[++num].next=head[from]; 14 e[num].to=to; 15 head[from]=num; 16 } 17 void tarjan(int x) 18 { 19 int flag=0; 20 dfn[x]=low[x]=++cnt; 21 for(int i=head[x];i;i=e[i].next) 22 { 23 int to=e[i].to; 24 if(!dfn[to]) 25 { 26 tarjan(to); 27 low[x]=min(low[x],low[to]); 28 if(dfn[x]<=low[to])//′ó?a??μ?3?·¢??2?μ?x 29 { 30 flag++; 31 if(x!=root||flag>1)//2?ê??ù?úμ??òo¢×óêy′óóú1 32 { 33 if(!cut[x]) tot++; 34 cut[x]=true; 35 } 36 } 37 } 38 else low[x]=min(low[x],dfn[to]); 39 } 40 } 41 int main() 42 { 43 scanf("%d%d",&n,&m); 44 for(int i=1;i<=m;i++) 45 { 46 int x,y; scanf("%d%d",&x,&y); 47 add(x,y); add(y,x); 48 } 49 for(int i=1;i<=n;i++) 50 if(!dfn[i]) 51 { 52 root=i; 53 tarjan(i); 54 } 55 printf("%d\n",tot); 56 for(int i=1;i<=n;i++) 57 if(cut[i]) 58 printf("%d ",i); 59 return 0; 60 }
标签:next lag \n std ace iostream efi fine names
原文地址:https://www.cnblogs.com/Slrslr/p/9502176.html