Given an undirected graph, each point after the request has been blocked ordered number of points (x, y) (x! = Y, 1 <= x, y <= n) of x and y can not be reached
First, the answer is not a cut point 2 * (n-1), the point to be considered is the cut point which communicates deleted blocks will be cut to separate
Consider tarjan process, core processing of the search tree, if the cut point, then removed communication block point x will be generated for all portions of the outer all to son subtree rooted and x subtree of x, each subtree contribution generated for the $ size [s1] * (n-size [s1]) contribution outside the $, x subtree $ (size [x]) * (n-size [x]) $, and x themselves as $ (n-1) $
#include<bits/stdc++.h> #define ll long long using namespace std; const int maxn=100009; const int maxm=500009; int n,m,tim,root; struct node{ int v,nxt; }e[maxm<<1]; int head[maxn],cnt=1; inline void add(int u,int v){ e[++cnt].v=v;e[cnt].nxt=head[u];head[u]=cnt; } int dfn[maxn],low[maxn];bool cut[maxn]; ll ans[maxn],sz[maxn]; void tarjan(int x){ dfn[x]=low[x]=++tim;sz[x]=1; int son=0,sum=0; for(int i=head[x];i;i=e[i].nxt){ int y=e[i].v; if(!dfn[y]){ tarjan(y);sz[x]+=sz[y]; low[x]=min(low[x],low[y]); if(low[y]>=dfn[x]){ son++; ANS [X] + = SZ [Y] * (n--SZ [Y]); // each point only to a point within the current subtree SUM = + SZ [Y]; IF ! (X = the root Son || > . 1 ) Cut [X] = . 1 ; } } the else Low [X] = min (Low [X], DFN [Y]); } IF (Cut [X]) ANS [X] + = 1LL * (N- sum- . 1 ) * (SUM + . 1 ) + (N- . 1 ); // outer sub-tree can not x and x to x subtree in all other points not to the else ANS [x] = 2 * (N- . 1 ) ; } int main () { Scanf ( " % D% D ",&n,&m); for(int i=1,u,v;i<=m;i++){ scanf("%d%d",&u,&v);if(u==v)continue; add(u,v);add(v,u); } for(int i=1;i<=n;i++) if(!dfn[i])root=i,tarjan(i); for(int i=1;i<=n;i++)printf("%lld\n",ans[i]); }