• <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 1144 Network---求無向圖割點數

            Posted on 2010-08-08 19:46 Uriel 閱讀(471) 評論(0)  編輯 收藏 引用 所屬分類: POJ圖論
                    赤裸裸的求割點數的題目,上模板~~
                    關于求割點的方法,黑書上講得比較詳細了

            //Problem: 1144  User: Uriel 
            //Memory: 228K  Time: 16MS 
            //Language: C++  Result: Accepted 
            //Cut Vertex
            //2010.08.06
            #include<stdio.h>
            #include
            <stdlib.h>
            #include
            <algorithm>
            using namespace std;
            #define N 110

            int n;
            int ancestor[N]; 
            int mark[N];
            int deep[N]; 
            int cnt[N];
            int adj[N][N];

            int DFS(int i,int father,int dth,int b[][N],int cut[]){
                
            int j,k,sons=0,count=0;
                mark[i]
            =1;
                deep[i]
            =ancestor[i]=dth;
                
            for(k=b[i][0];k>=1;k--){
                    j
            =b[i][k];
                    
            if(j!=father && mark[j]==1)ancestor[i]=min(ancestor[i],deep[j]); 
                    
            if(mark[j]==0){
                        count
            +=DFS(j,i,dth+1,b,cut);
                        sons
            ++;
                        ancestor[i]
            =min(ancestor[i],ancestor[j]);
                        
            if((father==-1&&sons>1)||(father!=-1&&ancestor[j]>=deep[i]))cut[i]=1;
                        
            //if(ancestor[j]>deep[i]) brige[i][j]=1;
                    }

                }

                mark[i]
            =2;
                
            return count+cut[i]; 
            }


            int cutpoints(int a[][N],int n,int cut[])
                
            int i,j,b[N][N],count=0;
                
            for(i=0;i<n;i++)cut[i]=b[i][0]=0;
                memset(mark,
            0,sizeof(mark));
                
            for(i=0;i<n;i++)for(j=0;j<n;j++)if(a[i][j])b[i][++b[i][0]]=j; 
                
            for(i=0;i<n;i++)if(mark[i]==0)count+=DFS(0,-1,0,b,cut); 
                
            return count;
            }


            int main(){
                
            int x,y;
                
            char c;
                 
            while(1){
                     scanf(
            "%d",&n);
                     
            if(!n)return 0;
                     memset(adj,
            0,sizeof(adj));
                     
            while(1){
                         scanf(
            "%d",&x);
                         
            if(x==0)break;
                         x
            --;
                         
            while(1){
                             scanf(
            "%d",&y);
                             y
            --;
                             adj[x][y]
            =1;adj[y][x]=1;
                             c
            =getchar();
                             
            if(c=='\n')break;
                         }

                     }

                     printf(
            "%d\n",cutpoints(adj,n,cnt));
                 }

                 
            return 0;
            }
                    
            99久久精品免费国产大片| 99久久婷婷国产综合亚洲| 97精品伊人久久大香线蕉| 亚洲av伊人久久综合密臀性色| 欧美亚洲色综久久精品国产| 色综合久久久久| 久久久久久综合网天天| 久久九九青青国产精品| 久久无码国产专区精品| 精品午夜久久福利大片| 国内精品久久久久影院亚洲| 久久久国产精品网站| 中文成人久久久久影院免费观看| 国产精品久久成人影院| 亚洲午夜无码久久久久| 久久人妻少妇嫩草AV无码蜜桃| 久久亚洲中文字幕精品有坂深雪| 久久性生大片免费观看性| 国产国产成人精品久久| 久久婷婷五月综合色奶水99啪| 久久精品国产WWW456C0M| 精品一区二区久久| 麻豆成人久久精品二区三区免费| 久久人人超碰精品CAOPOREN| 久久久国产精品福利免费| 亚洲成色WWW久久网站| 亚洲精品国精品久久99热一| 亚洲中文字幕伊人久久无码| 久久久亚洲精品蜜桃臀| 久久精品无码免费不卡| 一级做a爱片久久毛片| 7国产欧美日韩综合天堂中文久久久久 | 精品久久久久久国产牛牛app | 久久精品国产亚洲精品| 99久久国产亚洲高清观看2024| 91精品国产91久久综合| 国产精品久久久久久影院| 办公室久久精品| 亚洲精品成人网久久久久久| 亚洲中文字幕伊人久久无码| 久久久久久久综合狠狠综合|