• <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 ~
            <2025年7月>
            293012345
            6789101112
            13141516171819
            20212223242526
            272829303112
            3456789

            統計

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

            无码人妻久久一区二区三区 | 日韩va亚洲va欧美va久久| a高清免费毛片久久| 国产精品久久永久免费| 国产精品免费看久久久香蕉| 国产高清美女一级a毛片久久w| 久久这里只有精品视频99| 丁香色欲久久久久久综合网| 99麻豆久久久国产精品免费| 久久久久久国产a免费观看不卡 | 亚洲精品美女久久久久99小说| 欧美激情精品久久久久久久| 久久久久免费精品国产| 97精品久久天干天天天按摩| 久久国产成人精品国产成人亚洲| 精品国产乱码久久久久软件| 国产V综合V亚洲欧美久久| 久久久中文字幕日本| AV色综合久久天堂AV色综合在| 日本国产精品久久| 精品久久久久久久| 久久精品国产2020| 国产精自产拍久久久久久蜜| 久久久久亚洲av无码专区| 欧美亚洲另类久久综合婷婷| 久久国产高清字幕中文| 欧洲人妻丰满av无码久久不卡| 久久久久亚洲AV成人网人人软件| 久久se精品一区精品二区| 久久久久久国产精品无码下载 | 一级做a爱片久久毛片| 超级碰碰碰碰97久久久久| 久久996热精品xxxx| 欧美精品一区二区精品久久| 一本一本久久A久久综合精品| 日韩中文久久| 久久天天躁狠狠躁夜夜2020老熟妇| 色综合久久综精品| 91精品国产高清91久久久久久| 久久亚洲AV无码精品色午夜麻豆 | 欧美日韩精品久久久免费观看|