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

            Uriel's Corner

            Research Associate @ Harvard University / Research Interests: Computer Vision, Biomedical Image Analysis, Machine Learning
            posts - 0, comments - 50, trackbacks - 0, articles - 594

            POJ 3194 Equidivisions---DFS

            Posted on 2009-08-23 19:50 Uriel 閱讀(314) 評論(0)  編輯 收藏 引用 所屬分類: POJ搜索
            這類的DFS做了好幾道了。。終于感覺做起來輕松一點了。。
            /*  Problem: 3194  User: Uriel 
                Memory: 384K   Time: 16MS 
                Language: C++  Result: Accepted 
            */
               
            #include
            <stdio.h>
            #include
            <stdlib.h>
            #include
            <string.h>

            int ax[]={0,0,1,-1};
            int ay[]={1,-1,0,0};
            int i,j,n,x[110][110],s[110][250],f[110][110],k;

            bool Jge()
            {
                
            for(int i=1;i<=n;i++)
                
            {
                    
            for(int j=1;j<=n;j++)
                    
            {
                        
            if(x[i][j])return false;
                    }

                }

                
            return true;
            }


            int Pre(int x,int y)
            {
                
            if(x<=0 || x>|| y<=0 || y>n)
                    
            return 1;
                
            else
                    
            return 0;
            }


            void DFS(int a,int b)
            {
                
            int j;
                
            int tx,ty;
                
            for(j=0;j<4;j++)
                
            {
                    
                    tx
            =ax[j]+a;
                    ty
            =ay[j]+b;
                    
            if(!Pre(tx,ty) && x[tx][ty]==&& !f[tx][ty])
                    
            {
                        f[tx][ty]
            =1;
                        x[tx][ty]
            =0;
                        DFS(tx,ty);
                    }

                }

            }


            int main()
            {
                
            while(1)
                
            {
                    scanf(
            "%d",&n);
                    
            if(n==0)break;
                    memset(x,
            0,sizeof(x));
                    
            for(i=1;i<n;i++)
                    
            {
                        
            for(j=0;j<2*n;j++)
                        
            {
                            scanf(
            "%d",&s[i][j]);
                        }

                        
            for(j=0;j<2*n;j+=2)
                        
            {
                            x[s[i][j]][s[i][j
            +1]]=i;
                        }

                    }
             
                    
            for(i=1;i<n;i++)
                    
            {
                        
            for(j=1;j<=n;j++)
                        
            {
                            
            if(!x[i][j])x[i][j]=n;
                        }

                    }

                    memset(f,
            0,sizeof(f));
                    
            for(i=1;i<=n;i++)
                    
            {
                        
            for(j=1;j<=n;j++)
                        
            {
                            
            for(k=1;k<=n;k++)
                            
            {
                                
            if(x[j][k]==i)
                                
            {
                                    DFS(j,k);
                                }

                            }

                        }

                    }

                    
            if(Jge()==false)printf("wrong\n");
                    
            else
                        printf(
            "good\n");
                }

                system(
            "PAUSE");
                
            return 0;
            }


            感覺大概套路就是這樣了。。POJ 1562  3620 ...
            菜鳥剛學搜索,不足之處還請路過的大牛們指教
            久久无码国产| 国内精品久久久久久久coent| 欧美亚洲国产精品久久| 久久久精品久久久久影院| 精品人妻久久久久久888| 精品乱码久久久久久夜夜嗨| 亚洲精品国精品久久99热| 色8久久人人97超碰香蕉987| 国产欧美一区二区久久| 亚洲中文字幕伊人久久无码 | 国产一久久香蕉国产线看观看 | 久久精品无码一区二区三区免费 | 99久久无色码中文字幕人妻| 精品综合久久久久久97超人| 青青草原综合久久大伊人| 久久精品国产91久久麻豆自制| 一本色道久久综合| 国产91久久综合| MM131亚洲国产美女久久| 久久久午夜精品福利内容| 国产精久久一区二区三区| 国产精品欧美久久久天天影视| 久久天天躁夜夜躁狠狠躁2022| 国产免费久久精品丫丫| 老司机国内精品久久久久| 久久久这里有精品中文字幕| 九九久久精品无码专区| 久久人人爽爽爽人久久久| 99久久99久久精品国产片果冻| 久久久精品视频免费观看| 国产高清美女一级a毛片久久w | 久久精品国产亚洲精品| 国产精品午夜久久| 亚洲午夜久久久精品影院| 久久综合欧美成人| 99久久人妻无码精品系列| 久久综合给久久狠狠97色| 亚洲第一极品精品无码久久 | 久久久精品免费国产四虎| www.久久热.com| 久久久久久免费一区二区三区|