• <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 閱讀(1009) 評論(10)  編輯 收藏 引用 所屬分類: POJ
            亚洲香蕉网久久综合影视| 国产美女亚洲精品久久久综合| 国产精品99久久久精品无码| 国产成人久久久精品二区三区| 免费无码国产欧美久久18| 人人狠狠综合久久亚洲| 热99re久久国超精品首页| 久久综合九色综合网站 | 久久这里都是精品| 精品无码久久久久久久久久| 国产精品美女久久久| 色狠狠久久AV五月综合| 亚洲精品乱码久久久久久| 久久精品国产男包| 丁香色欲久久久久久综合网| 色综合久久夜色精品国产| 91麻豆国产精品91久久久| 久久这里只精品99re66| 亚洲中文字幕久久精品无码喷水| 狠狠色丁香久久婷婷综合蜜芽五月| 久久久国产99久久国产一| 国内精品人妻无码久久久影院导航| 欧美国产成人久久精品| 久久夜色精品国产噜噜亚洲AV| 欧美黑人激情性久久| 国产欧美久久久精品| 夜夜亚洲天天久久| 久久天天日天天操综合伊人av| 久久青青草原精品国产不卡| 午夜精品久久久久久影视riav| 久久久久高潮综合影院| 国内精品久久久久影院日本| 7国产欧美日韩综合天堂中文久久久久 | 午夜精品久久久内射近拍高清| 国产精品久久久香蕉| 久久国产精品成人片免费| 久久国产乱子伦精品免费强| 久久婷婷五月综合97色直播| 久久亚洲AV成人无码| 99久久久国产精品免费无卡顿| 国产L精品国产亚洲区久久|