• <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 閱讀(457) 評論(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香蕉久| 国产毛片欧美毛片久久久| 久久久久亚洲av无码专区| 久久99热精品| 久久久久久国产a免费观看黄色大片| 久久精品极品盛宴观看| 久久国产亚洲精品麻豆| 久久久久免费精品国产| 99久久精品免费观看国产| 日韩乱码人妻无码中文字幕久久| 久久精品国内一区二区三区| 综合久久精品色| 久久99精品免费一区二区| 精品久久久无码人妻中文字幕豆芽 | 亚洲国产综合久久天堂| 精品少妇人妻av无码久久| 国产成人综合久久精品红| 99久久精品久久久久久清纯| 久久亚洲精品无码AV红樱桃| 少妇无套内谢久久久久| 亚洲国产婷婷香蕉久久久久久| 久久亚洲国产中v天仙www| 亚洲级αV无码毛片久久精品| 久久精品国产福利国产琪琪| 亚洲天堂久久精品| 91精品国产高清91久久久久久| 久久久久久精品免费看SSS | 国产精品久久久久影视不卡| 久久婷婷国产剧情内射白浆| 美女久久久久久| 亚洲精品乱码久久久久久不卡| 久久精品成人免费国产片小草| 99久久精品免费国产大片| 7国产欧美日韩综合天堂中文久久久久| 亚洲日韩中文无码久久| 日本久久久久亚洲中字幕| 人妻无码久久一区二区三区免费 | 91精品国产91久久| 国产精品午夜久久|