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

小顶堆+DFS,不过WA,求测试数据

Posted by Koala007 at 2010-06-15 02:16:10 on Problem 2227
初用C++,vector<>::iterator在插入元素后会失效,错了一次。
数据范围long long,应该没有问题,求BT数据
基本结构
main(){
    所有边节点入vec;
    make_heap()
    while(!vec.empty()){
        p = vec.front();
        vec.erase(vec.begin())
        floodDFS();
    }
    sum +=...;
}
floodDFS(p,value)
{  
   for(上下左右)
     if(合法){
          p1=p+d[][];
          if(h(p1)<=h(p)){
              L(p1)=value;
              flood(p1,value)
          }else{
              L(p1)=-1;
              vec.push_back();
              make_heap()//调整一下堆
          }
     }
}

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