• <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 閱讀(1015) 評論(10)  編輯 收藏 引用 所屬分類: POJ
            成人亚洲欧美久久久久| 久久亚洲精品国产亚洲老地址| 久久久精品波多野结衣| 国产精品99久久久久久www| 久久亚洲AV无码西西人体| 久久夜色精品国产亚洲| 久久福利青草精品资源站| 久久久久久亚洲精品不卡| 97精品依人久久久大香线蕉97| 国产精品美女久久久| 久久久中文字幕日本| 久久久无码一区二区三区| 久久久精品久久久久久| 亚洲中文久久精品无码| 国产精品无码久久久久| 日韩av无码久久精品免费| 久久久WWW成人免费精品| 久久精品一本到99热免费| 久久最新免费视频| 国产亚洲成人久久| 久久久久亚洲av无码专区| 国产精品中文久久久久久久| 青青草国产精品久久| 国产亚洲综合久久系列| 久久综合成人网| 国内精品久久久久影院网站| 精品无码久久久久久尤物| 精品久久久久成人码免费动漫| 国产福利电影一区二区三区久久久久成人精品综合 | 久久国产精品99精品国产| 久久99精品久久久久久野外| 97r久久精品国产99国产精| 久久亚洲sm情趣捆绑调教| 久久久久久狠狠丁香| 久久久婷婷五月亚洲97号色| 久久婷婷国产剧情内射白浆| 久久精品综合网| 综合久久给合久久狠狠狠97色| 久久精品三级视频| 免费精品久久久久久中文字幕| 国内精品久久久久久麻豆|