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 |
天那,为什么,我自己写的pop_heap函数死活就不对呢,换了STL才让过,哪位仁兄来看下阿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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator