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

天那,为什么,我自己写的pop_heap函数死活就不对呢,换了STL才让过,哪位仁兄来看下阿

Posted by xiaox at 2007-07-24 14:02:31 on Problem 2449
In Reply To:如果有若干条路径相同的时候怎么算 Posted by:xiaox at 2007-07-20 10:03:06
PushHeap 函数可以过,PopHeap就是不对,我这辈子都是这么写的

typedef struct BNODE
{
	int v,wt,f;
}BNODE;

void PopHeap()
{
	h_len--;
	int i=0,j=1;
	heap[0] = heap[h_len];
	BNODE x = heap[0];
	while (j<h_len)
	{
		if (j+1<h_len && heap[j].f > heap[j+1].f) j++;
		if (x.f <= heap[j].f) break;
		i = j;
		j = i+i+1;
	}
	heap[i] = x;
}

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