• <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>
            posts - 100,  comments - 15,  trackbacks - 0
            //很有趣的一題,讓我想起口袋怪獸
            WA了老半天,原來是兩個if()放反了,居然不判RE判WA,o(╯□╰)o
            #include<iostream>
            using namespace std;
            char map[21][21];
            int dx[4]={0,-1,0,1};
            int dy[4]={-1,0,1,0};
            int h,w,sx,sy;
            int step;
            int res;
            void dfs(int x,int y)
            {
                
            int dir,tx,ty;
                
            if(step>=10return ;
                
            for(dir=0;dir<4;dir++)
                
            {
                    tx
            =x;ty=y;
                    
            while(1)
                    
            {
                        tx
            =tx+dx[dir]; ty=ty+dy[dir];
                        
            if(tx<0 || tx>=|| ty<0 || ty>=w   )break;            
                        
            if(map[tx][ty]=='3')
                        

                            step
            ++
                            
            //printf("--%d--\n",step);
                            if(res>step) res=step; 
                            step
            --;
                            
            return ;
                        }

                        
            else 
                            
            if(map[tx][ty]=='1'
                            
            {
                                tx
            =tx-dx[dir];ty=ty-dy[dir]; 
                                
            if(tx!=|| ty!=y) 
                                
            {
                                    map[tx
            +dx[dir]][ty+dy[dir]]='0';
                                    step
            ++;
                                    dfs(tx,ty);
                                    step
            --;
                                    map[tx
            +dx[dir]][ty+dy[dir]]='1';
                                }

                                
            break;
                            }

                    }
            //while    
                }
            //for
            }
            //dfs

            int main()
            {
                
            int i,j;
                
                
            while(scanf("%d%d",&w,&h)!=EOF && w)
                
            {
                    step
            =0;
                    
            for(i=0;i<h;i++)
                        
            for(j=0;j<w;j++)
                        scanf(
            " %c",&map[i][j]);
                    
            for(i=0;i<h;i++)
                        
            for(j=0;j<w;j++)
                            
            if(map[i][j]=='2'{sx=i;sy=j;break;}
                    res
            =9999999;
                    dfs(sx,sy);
                    
            if(res>10) printf("-1\n");
                    
            else printf("%d\n",res);
                }

                
            return 0;
            }

            posted on 2009-07-22 23:46 wyiu 閱讀(1031) 評論(10)  編輯 收藏 引用 所屬分類: POJ
            99久久综合狠狠综合久久| 91精品无码久久久久久五月天| 女人高潮久久久叫人喷水| 久久天天躁夜夜躁狠狠躁2022| 久久精品天天中文字幕人妻| 青青草原1769久久免费播放| 精品久久久久久久久免费影院| 亚洲嫩草影院久久精品| 婷婷久久综合九色综合绿巨人| 久久久精品2019免费观看| 久久99久久无码毛片一区二区| 久久精品国内一区二区三区| 久久久SS麻豆欧美国产日韩| 色综合久久久久网| 亚洲女久久久噜噜噜熟女| 伊人伊成久久人综合网777| 久久精品国产亚洲5555| 久久久久久极精品久久久| 久久久久亚洲av无码专区导航 | 久久精品国产91久久综合麻豆自制| 久久久WWW免费人成精品| 精品久久777| 精品久久8x国产免费观看| 无遮挡粉嫩小泬久久久久久久 | 欧美一区二区久久精品| 大美女久久久久久j久久| 精品久久一区二区| 精品久久久久久亚洲精品 | 久久精品中文騷妇女内射| 四虎影视久久久免费| 精品久久国产一区二区三区香蕉| 国内精品久久久人妻中文字幕| 亚洲AV无码久久精品成人 | 久久久中文字幕日本| 欧美久久一区二区三区| 久久久久亚洲AV成人网| 2021国产成人精品久久| 99久久免费国产精品| 国产成人久久精品二区三区| 久久涩综合| 久久精品中文字幕一区|