设为首页 加入收藏

TOP

hdu2128之BFS (二)
2014-11-23 21:42:23 来源: 作者: 【 】 浏览:6
Tags:hdu2128 BFS
int dir[4][2]={0,1,0,-1,1,0,-1,0}; struct Node{ int x,y,num,time; unsigned long long open;//表示已经炸过的墙(最多8*8位) unsigned long long key;//表示已经取过的炸药位置(最多8*8) Node(){} Node(int X,int Y,int Num,int Time,unsigned long long Open,unsigned long long Key){ x=X,y=Y,num=Num; time=Time,open=Open,key=Key; } bool operator<(Node const &a)const{ return time>a.time; } }start; bool check(Node &next){ int size=mark[next.x][next.y][next.num].size(); for(int i=0;iq; Node oq,next; q.push(start); while(!q.empty()){ oq=q.top(); q.pop(); for(int i=0;i<4;++i){ next=Node(oq.x+dir[i][0],oq.y+dir[i][1],oq.num,oq.time+1,oq.open,oq.key); if(next.x<0 || next.y<0 || next.x>=n || next.y>=m)continue; if(Map[next.x][next.y] == 'X'){//该点是墙 int k=next.x*m+next.y; if( !((next.open>>k)&1) )--next.num,++next.time;//是否已炸过 next.open|=((1ll)<='1' && Map[next.x][next.y]<='9'){//该点有炸药可取 int k=next.x*m+next.y; if( !((next.key>>k)&1) )next.num+=Map[next.x][next.y]-'0';//是否已取过 next.key|=((1ll)<>n>>m,n+m){ Init(); memset(mark,-1,sizeof mark); for(int i=0;i>Map[i]; for(int i=0;i

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇uva 10273 Eat or Not to Eat? 下一篇HDU4528+BFS

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·一篇说人话的文章, (2025-12-27 07:50:09)
·Python Web框架哪家 (2025-12-27 07:50:06)
·基于Python的数据分 (2025-12-27 07:50:03)
·深入理解 Java 集合 (2025-12-27 07:22:48)
·Java集合框架全面解 (2025-12-27 07:22:45)