topic:
Seeking an undirected graph will go through from point N 1
n<=2e5 m<=4e5
analysis:
A necessary point means: After deleting the entire graph is not connected, but can not find a cut point directly. Because the deleted point can not communicate FIG, 1 and n can not be guaranteed but not in communication.
So you want to delete that point on the path 1 to n. That is, points can be deleted and n 1 are separated.
Method 1:
tarjan sentenced to ring when starting at 1, and maintains an array siz [v]: at this point there is no representation v n at this point in the sub-tree search, every time back when the flag back to u (u is v's father).
In the cut point judgment conditions: low [v] <= dfn [u] (u subtree than can not reach the point u) plus a limit: siz [v] == 1 (v subtree has n )
Why not siz [u] == 1?
V u possible non subtree has n, u 1 and n after removing still connected.
Method 2:
When this loop judgment condition to pay more: dfn [v] <= dfn [n] (n v ratio after traversed)
Paint, the requirement that Italy
#include<bits/stdc++.h> using namespace std; #define N 200005 #define ri register int int siz[N],low[N],nex[N<<2],head[N],to[N<<2],dfn[N],cut[N]; int Ti=0,tot=0,n,m,ans=0; int read() { int x=0,fl=1; char ch=getchar(); while(ch<'0'||ch>'9') { if(ch=='-') fl=-1; ch=getchar(); } while(ch<='9'&&ch>='0') x=x*10+ch-'0',ch=getchar(); return x*fl; } void add(int a,int b) { to[++tot]=b; nex[tot]=head[a]; head[a]=tot; to[++tot]=a; nex[tot]=head[b]; head[b]=tot; } void dfs(int u,intFA) { DFN [U] = Low [U] = ++ of Ti; IF (n-== U) SIZ [U] = . 1 ; BOOL Flagg = 0 ; for (I = RI head [U]; I; I = NEX [I]) { int V = to [I]; IF (DFN [V] && V =!! FA) { DFS (V, U); Low [U] = min (Low [U], Low [V ]); SIZ [U] | = siz [v]; IF (siz [v] && Low [V]> = DFN [U]) = Flagg . 1 ; // this must siz [v] In order to guarantee from v subtree pass up tags instead transmitted from another subtree of up tag u //U is a judgment because there is a cut point subtree judged v // That is cut off after the u and v sub-tree split other portions will be just n subtrees without the v 1 and in a block / / there is a play: dfn [v] <= dfn [n] ( n after that is traversed v) // 1. v n in the subtree 2.n another non u v in the sub-tree (since n must traverse dfn advance value so that the accuracy can be guaranteed only) } the else IF (FA = V!) Low [U] = min (Low [U], dfn [V]); } IF ( ! U = . 1 && Flagg) ANS ++, Cut [U] = . 1 ; } int main () { // The freopen ( "home.in", "R & lt", stdin); // The freopen ( "home.out", " W ", stdout); int T = Read (); while(T--){ n=read(); m=read(); while(m--) add(read(),read()); dfs(1,0); printf("%d\n",ans); for(ri i=1;i<=n;++i) if(cut[i]) printf("%d ",i); printf("\n"); for(ri i=1;i<=n;++i) dfn[i]=nex[i]=to[i]=head[i]=low[i]=siz[i]=cut[i]=0; Ti=0; tot=0; ans=0; } } /* 1 10 11 1 10 10 6 6 7 7 8 8 5 5 3 3 9 9 4 4 2 6 2 8 7 */