HDU 2579 Dating with girls(2)

2015-07-20 17:07:36 ? 作者: ? 浏览: 3

补考跪了。果然我讨厌网络技术……学什么cisco的软件操作。简直!!!

计算机网络的东西讲得又浅。发的又是一本纯英文的《计算机网络》的书。真装逼的学校。

字典一样厚,我真想砸死你!真是看得起我们,985,211的本科都没这么?。

赶紧做几道题压压惊。随机翻一页,题目倒是不错,约会……


题意简单,就是找妹子约会(Orz)。迷宫的#代表石头,在k的倍数的时候不能走。

记得vis为三维,因为可以往回走。

接下来就是一个bfs而已。


#include
  
   
#include
   
     #include
    
      #include
     
       #include
      
        #include
        #include
        
          #include
         
           #include
          
            #include
           
             #include
            
              #include
             
               #include
              
                #define INF 0x7fffffff #define eps 1e-8 #define LL long long #define PI 3.141592654 #define CLR(a,b) memset(a,b,sizeof(a)) #define FOR(i,a,b) for(int i=a;i
               
                =b;i--) #define sf scanf #define pf printf #define all(v) (v).begin(),(v).end() #define acfun std::ios::sync_with_stdio(false) #define SIZE (100 +2) #define MOD 1000000007 using namespace std; char g[SIZE][SIZE]; int t,n,m; int xx[]={0,0,-1,1}; int yy[]={-1,1,0,0}; struct node { int x,y,s; void init(int _x,int _y,int _s=0) { x=_x,y=_y,s=_s; } }; node Y,G; void bfs() { bool vis[SIZE][SIZE][11]; CLR(vis,0); queue
                
                 q; q.push(Y); vis[Y.x][Y.y][0]=1; while(!q.empty()) { node tmp=q.front(); q.pop(); //pf("%d %d=%d\n",tmp.x+1,tmp.y+1,tmp.s); if(tmp.x==G.x&&tmp.y==G.y) { pf("%d\n",tmp.s); return; } FOR(k,0,4) { int x=tmp.x+xx[k]; int y=tmp.y+yy[k]; int s=tmp.s+1; if(x<0||x>=n||y<0||y>=m||vis[x][y][s%t]) continue; if(g[x][y]=='#'&&s%t!=0)continue; node now; vis[x][y][s%t]=1; now.init(x,y,s); q.push(now); } } puts("Please give me another chance!"); } int main() { int T; sf("%d",&T); while(T--) { sf("%d%d%d",&n,&m,&t); FOR(i,0,n) { sf("%s",g[i]); FOR(j,0,m) { if(g[i][j]=='Y') Y.init(i,j); else if(g[i][j]=='G') G.init(i,j); } } bfs(); } return 0; } 
                
               
              
             
            
           
          
         
        
      
     
    
   
  


-->

评论

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