Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
提供两组数据都说是求割点,其实感觉是求块 两组数据构成的图是一样的,只是插入边的顺序不一样 5 1 3 2 2 4 5 3 4 5 0 5 1 2 3 2 3 4 5 4 5 0 都输出:1 void tarjan(int u,int father){ dfn[u]=low[u]=++index; for(int i=head[u];i != -1;i=edge[i].next){ int v=edge[i].v; if(v == father)continue; if(!dfn[v]){ tarjan(v,u); if(low[v]>=dfn[u])++sum[u]; low[u]=min(low[u],low[v]); }else low[u]=min(low[u],dfn[v]); //low[u]=min(low[u],low[v]); } } 注意else 的时候一定要是low[u]=min(low[u],dfn[v]);而不是low[u]=min(low[u],low[v]); 想一下就知道了,其实求块要分if else也是这个原因 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator