Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

提供两组数据

Posted by 2280103398 at 2014-03-04 22:09:51 on Problem 1144
都说是求割点,其实感觉是求块
两组数据构成的图是一样的,只是插入边的顺序不一样
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator