• <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 - 106,  comments - 32,  trackbacks - 0

            這道題 就是利用匈牙利算法 然后將問題轉化為 最大匹配問題 view plaincopy to clipboardprint?
            #include  <iostream>   
             

            const   int   MaxN = 500 + 1;   
            bool   map[MaxN][MaxN] , ck[MaxN];   
            int     n , match[MaxN] , max_match , k;    
            bool  search(int x)   
            {   
                  
            int i , t;   
                  
            for (i = 1 ; i <= n ; i ++)   
                  
            if (map[i][x]&&!ck[i])   
                  
            {   
                      ck[i] 
            = true;   
                      t 
            = match[i];   
                      match[i] 
            = x;   
                      
            if (t ==0 || search(t)) return true;   
                      match[i] 
            = t;                              
                  }
               
                  
            return false;         
            }
               
            void  hungary()   
            {   
                  
            int  i ;   
                  memset(match , 
            0 , sizeof(match));   
                  max_match 
            = 0;   
                  
            for ( i = 1 ; i <= n ; i ++)   
                  
            {   
                     memset(ck , 
            false , sizeof(ck));   
                     
            if (search(i)) max_match++;   
                  }
                     
            }
               
            int   main()   
            {   
                    
                  
            int i  , x , y;   
                  scanf(
            "%d%d",&n,&k);   
                  
            for ( i = 1 ; i <= k ; i++)   
                  
            {   
                          scanf(
            "%d%d",&x,&y);   
                          map[x][y] 
            = true;   
                  }
               
                  hungary();   
                  printf(
            "%d\n",max_match);    
                     
                  
            return 0;         
            }
              
            #include  
            <iostream>

            const   int   MaxN = 500 + 1;
            bool   map[MaxN][MaxN] , ck[MaxN];
            int     n , match[MaxN] , max_match , k; 
            bool  search(int x)
            {
                  
            int i , t;
                  
            for (i = 1 ; i <= n ; i ++)
                  
            if (map[i][x]&&!ck[i])
                  
            {
                      ck[i] 
            = true;
                      t 
            = match[i];
                      match[i] 
            = x;
                      
            if (t ==0 || search(t)) return true;
                      match[i] 
            = t;                           
                  }

                  
            return false;      
            }

            void  hungary()
            {
                  
            int  i ;
                  memset(match , 
            0 , sizeof(match));
                  max_match 
            = 0;
                  
            for ( i = 1 ; i <= n ; i ++)
                  
            {
                     memset(ck , 
            false , sizeof(ck));
                     
            if (search(i)) max_match++;
                  }
                  
            }

            int   main()
            {
                 
                  
            int i  , x , y;
               scanf(
            "%d%d",&n,&k);
                  
            for ( i = 1 ; i <= k ; i++)
                  
            {
                          scanf(
            "%d%d",&x,&y);
                          map[x][y] 
            = true;
                  }

                  hungary();
                  printf(
            "%d\n",max_match); 
                  
                  
            return 0;      
            }

             

             

             完全是 模板的套用 呵呵


             

            posted on 2009-08-04 17:05 付翔 閱讀(931) 評論(0)  編輯 收藏 引用

            <2009年8月>
            2627282930311
            2345678
            9101112131415
            16171819202122
            23242526272829
            303112345

            常用鏈接

            留言簿(2)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            CSDN - 我的blog地址

            博客

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            久久99精品久久久久久久不卡| 欧美日韩精品久久久免费观看| 久久久久久曰本AV免费免费| 国产成人久久精品一区二区三区| 亚洲人成网亚洲欧洲无码久久| 久久久久青草线蕉综合超碰| 人妻无码久久一区二区三区免费| 国产高清美女一级a毛片久久w | 精品国产乱码久久久久软件| 日韩人妻无码一区二区三区久久99| 亚洲va久久久噜噜噜久久| 国产午夜精品理论片久久影视| 久久久久亚洲av成人网人人软件 | 99久久精品日本一区二区免费| 国产精品成人久久久久三级午夜电影 | 77777亚洲午夜久久多喷| 色天使久久综合网天天| 久久免费精品一区二区| 7777久久亚洲中文字幕| 久久久久99这里有精品10| 久久久久99精品成人片| 99久久精品免费看国产免费| 热久久国产精品| 久久人人爽人人爽人人片av高请| 久久亚洲国产最新网站| 国产香蕉97碰碰久久人人| 久久久久香蕉视频| 亚洲成色999久久网站| 99久久人妻无码精品系列蜜桃| 日产精品久久久久久久| 一本色道久久88精品综合| 精品久久久无码人妻中文字幕| 久久国产影院| 久久免费观看视频| 久久水蜜桃亚洲av无码精品麻豆 | 精品久久国产一区二区三区香蕉| 久久99免费视频| 精品久久久久久国产三级| 久久久久国产一级毛片高清板| 国产一区二区精品久久凹凸| 久久精品国产一区二区 |