• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            哇哦~這就是我

            This is my way ~
            <2008年5月>
            27282930123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            統(tǒng)計

            • 隨筆 - 10
            • 文章 - 0
            • 評論 - 2
            • 引用 - 0

            常用鏈接

            留言簿(1)

            隨筆檔案

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            push!

            #include<iostream>
            #include<queue>
            #include<cmath>
            using namespace std;
            struct NODE
            {
             int p_x,p_y,step,c_x,c_y,d;
            };
            queue<NODE> que;
            const int MAXN = 100;
            bool p[MAXN][MAXN][4],c[MAXN][MAXN];
            int map[MAXN][MAXN];
            int mv[4][2]={-1,0,0,1,1,0,0,-1},p_sm,p_sn,c_sm,c_sn,m,n;
            void init ( )
            {
             memset(p,false,sizeof(p));
             for ( int i=0 ; i<m ; i++ )
              for ( int j=0 ; j<n ; j++ )
              {
               scanf("%d",&map[i][j]);
               if ( map[i][j]==4 )
                p_sm=i,p_sn=j;
               else
                if ( map[i][j]==2 )
                 c_sm=i,c_sn=j;
              }
            }
            int bfs ( )
            {
             NODE temp,go;
             int i;
             temp.p_x = p_sm;
             temp.p_y = p_sn;
             temp.c_x = c_sm;
             temp.c_y = c_sn;
             temp.step = 0;
             temp.d=0;
             for ( i=0 ; i<4 ; i++ )
             {
              p[p_sm][p_sn][i]=true;
              temp.d=i;
              que.push(temp);
             }
             c[c_sm][c_sn]=true;
             while ( !que.empty () )
             {
              NODE head=que.front();
              que.pop() ;
              for ( i=0 ; i<4 ; i++ )
              {
               int tm=head.p_x+mv[i][0] , tn=head.p_y+mv[i][1] ;
               if ( tm>=0 && tm<m && tn>=0 && tn<n && !p[tm][tn][i] && i!=(head.d+2)%4 && map[tm][tn]!=1 )
               {
                double t=sqrt( (double)( (tm-head.c_x)*(tm-head.c_x) ) +(double)( (tn-head.c_y)*(tn-head.c_y) ));
                if ( t <= sqrt(2.0) && t>0 )
                {
                 go=head;
                 go.p_x = tm;
                 go.p_y = tn;
                 go.step ++ ;
                 go.d=i;
                 p[tm][tn][i]=true;
                 que.push(go);
                }
                else
                {
                 int tmm=tm+mv[i][0] , tnn=tn+mv[i][1];
                 if ( t==0 && tmm>=0 && tmm<m && tnn>=0 && tnn<n && map[tmm][tnn]!=1 && !c[tmm][tnn] )
                 {
                  go.c_x = tmm ;
                  go.c_y = tnn ;
                  go.p_x = tm;
                  go.d=i;
                  go.p_y = tn;
                  go.step = head.step+1;
                  if ( map[tmm][tnn]==3 )
                   return go.step ;
                  c[tmm][tnn]=true;
                  p[tm][tn][i]=true;
                  que.push(go);
                 }
                }
               }
              }
             }
             return -1;
            }
            int main ( )
            {
             while ( scanf("%d%d",&n,&m)!=EOF )
             {
              init();
              printf("%d\n",bfs());
             // que.

             }
            }

            posted on 2008-05-28 01:36 chinaeli 閱讀(201) 評論(0)  編輯 收藏 引用

            无码人妻久久一区二区三区蜜桃 | 国内精品伊人久久久久777| 久久精品女人天堂AV麻| 欧美午夜A∨大片久久 | 久久精品国产亚洲AV麻豆网站| 久久久久久久人妻无码中文字幕爆| 久久久久国产一级毛片高清版| 久久人人爽人爽人人爽av| 久久久精品国产sm调教网站 | 国产成人精品久久综合 | 久久久精品人妻一区二区三区蜜桃| 久久精品国产影库免费看| 亚洲日本va午夜中文字幕久久| 久久天天躁狠狠躁夜夜网站| 国产毛片久久久久久国产毛片| 蜜臀av性久久久久蜜臀aⅴ| 久久国产精品无码网站| www久久久天天com| 国产美女亚洲精品久久久综合| 日本精品久久久久中文字幕8| 久久久一本精品99久久精品88| 中文字幕成人精品久久不卡| 无码精品久久久天天影视 | 囯产极品美女高潮无套久久久| 久久精品成人影院| 99久久免费国产精精品| 色狠狠久久AV五月综合| 久久人人爽人人爽人人片av麻烦 | 久久久免费精品re6| 伊人久久大香线蕉AV一区二区| 99久久无码一区人妻| 久久99精品综合国产首页| 久久精品无码午夜福利理论片| 久久青青草视频| 一本久久a久久精品综合香蕉| 久久精品一区二区三区中文字幕 | 中文字幕无码久久久| 婷婷国产天堂久久综合五月| 亚洲v国产v天堂a无码久久| 午夜精品久久久久成人| 思思久久99热只有频精品66|