HDU 2579 Dating with girls (2)

Source: Internet
Author: User
Tags bitset cmath

HDU 2579 Dating with girls (2)

Fail the retake exam. I hate network technology ...... Cisco Software operations. That's it !!!

Computer Networks are simple. It is also a book in English "Computer Network. A school that is truly forced.

The dictionary is as thick as it is. I really want to kill you! We really can afford it. 985,211 of undergraduate students are not so cool.

I was shocked by a few questions. Randomly flip one page. The question is good. Dating ......


It is easy to ask for a sister appointment (Orz ). The # Of the maze represents the stone, and cannot go at a multiple of k.

Remember that vis is 3D, because we can go back.

The next step is a 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 1000000007using 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;}
              
             
            
           
          
         
        
       
      
    
   
  
 


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.