设为首页 加入收藏

TOP

HDU 1253 胜利大逃亡(BFS)
2015-07-20 18:01:58 来源: 作者: 【 】 浏览:2
Tags:HDU 1253 胜利 逃亡 BFS
#include 
  
   
#include 
   
     #include 
    
      #include 
     
       #include 
      
        using namespace std; struct node{ int x,y,z,step; }; int ma[51][51][51]; int A,B,C,T; int mv[6][3] = {{1,0,0},{0,1,0},{0,0,1},{-1,0,0},{0,-1,0},{0,0,-1}}; //bool vis[51][51][51];开标记数组爆了两次内存,果断删掉 void BFS() { queue
       
        q; node f,t; f.x = 0; f.y = 0; f.z = 0; f.step = 0; q.push(f); ma[f.x][f.y][f.z] = 1; while(!q.empty()) { t = q.front(); q.pop(); if(t.x==A-1&&t.y==B-1&&t.z==C-1 && t.step <= T) { printf("%d\n",t.step); return; } for(int i = 0;i<6;i++) { f.x = t.x + mv[i][0]; f.y = t.y + mv[i][1]; f.z = t.z + mv[i][2]; if(0<=f.x && f.x
        
         

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇栈(二)――用栈来实现逆波兰式 下一篇POJ3368 Frequent values 线段树

评论

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