hdu 5094 Maze bfs

2015-01-27 10:14:45 · 作者: · 浏览: 9

传送门:上海邀请赛E

给定一个n×m的迷宫,给出相邻格子之间的墙或者门的信息,墙说明不可走,如果是门则需要有对应的钥匙才能通过,问是否能够从(1,1)到达(n,m)


一个带状态的bfs,再另记一个状态表示所带钥匙的种类,钥匙种类数最多只有10,因此可以用位来表示钥匙的状态。

/******************************************************
 * File Name:   5094.cpp
 * Author:      kojimai
 * Create Time: 2014年11月03日 星期一 09时24分27秒
 ******************************************************/

#include
  
   
#include
   
     #include
    
      #include
     
       #include
      
        #include
       
         using namespace std; #define FFF 55 bool vis[FFF][FFF][2048]; int map[FFF][FFF],road[FFF][FFF][4]; int move[4][2] ={-1,0,0,1,1,0,0,-1};//0-up 1-right 2-down 3-left struct node { int x,y,t,key; }now,tmp; queue
        
          pp; int getg(int g) { if(g == 0) return -1; else return 1 << g; } void solve(int x1,int y1,int x2,int y2,int g) { if(x1 == x2) { if(y1
          
            
          
<script type="text/java script">BAIDU_CLB_fillSlot("771048");
点击复制链接 与好友分享! 回本站首页
<script> function copyToClipBoard(){ var clipBoardContent=document.title + '\r\n' + document.location; clipBoardContent+='\r\n'; window.clipboardData.setData("Text",clipBoardContent); alert("恭喜您!复制成功"); }
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];