| ||||||||||
| 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 | |||||||||
小顶堆+DFS,不过WA,求测试数据初用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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator