• <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

            統計

            • 隨筆 - 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)  編輯 收藏 引用

            久久精品国产2020| 伊人久久大香线蕉综合热线| 丁香狠狠色婷婷久久综合| 精品午夜久久福利大片| 久久久久国产精品三级网| 久久久久亚洲av成人无码电影| 99久久综合国产精品免费| 麻豆成人久久精品二区三区免费| 人人狠狠综合久久亚洲88| 精品久久人人爽天天玩人人妻| 久久伊人精品青青草原高清| 国产精品久久婷婷六月丁香| 国产真实乱对白精彩久久| 久久亚洲精品无码AV红樱桃| 久久精品国产亚洲Aⅴ蜜臀色欲 | 久久久久久伊人高潮影院| 久久精品九九亚洲精品| 久久久黄色大片| 欧美激情精品久久久久久| 麻豆精品久久久一区二区| 久久国产色AV免费看| 狠狠综合久久综合88亚洲| 一级做a爰片久久毛片毛片| 91精品国产91久久| 2021精品国产综合久久| 久久精品亚洲精品国产色婷| 亚洲国产另类久久久精品| 狠狠色丁香久久婷婷综合图片| 久久最新免费视频| 久久亚洲精品无码观看不卡| 狠狠色丁香婷婷久久综合五月| 久久九九全国免费| 午夜精品久久久久久久| 99久久99久久| 久久综合丁香激情久久| 97精品伊人久久久大香线蕉| 四虎国产精品免费久久5151| 人人妻久久人人澡人人爽人人精品| 9久久9久久精品| 一本一本久久a久久精品综合麻豆| 午夜精品久久久久久毛片|