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

            這道題 就是利用匈牙利算法 然后將問題轉(zhuǎn)化為 最大匹配問題 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 付翔 閱讀(932) 評論(0)  編輯 收藏 引用

            <2011年7月>
            262728293012
            3456789
            10111213141516
            17181920212223
            24252627282930
            31123456

            常用鏈接

            留言簿(2)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            CSDN - 我的blog地址

            博客

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            久久精品国产99国产电影网| 超级碰久久免费公开视频| 99久久精品无码一区二区毛片 | 18岁日韩内射颜射午夜久久成人| 国产三级精品久久| 狠狠色伊人久久精品综合网| 一本伊大人香蕉久久网手机| 国产香蕉97碰碰久久人人| 久久精品国产国产精品四凭| 久久久久久极精品久久久| 伊人久久大香线蕉综合5g| 国产aⅴ激情无码久久| 一本色道久久HEZYO无码| 狠狠色丁香久久婷婷综合五月| 国产欧美一区二区久久| 精品无码久久久久久久动漫| 亚洲国产精品综合久久一线| 亚洲日韩中文无码久久| 国产精品免费福利久久| 99久久精品免费| 69久久夜色精品国产69| 久久亚洲电影| 九九精品99久久久香蕉| 久久国产精品波多野结衣AV| 久久综合亚洲鲁鲁五月天| 久久综合久久综合久久综合| 人妻无码精品久久亚瑟影视| 丰满少妇人妻久久久久久| 久久天天躁狠狠躁夜夜2020 | 日韩中文久久| 久久国产成人精品麻豆| 色青青草原桃花久久综合| AV无码久久久久不卡网站下载| 亚洲国产成人久久综合碰碰动漫3d | 国产精品久久久久久久app| 2021精品国产综合久久| 一本久久综合亚洲鲁鲁五月天亚洲欧美一区二区 | 国产L精品国产亚洲区久久| 久久精品日日躁夜夜躁欧美| 7国产欧美日韩综合天堂中文久久久久| 亚洲欧美久久久久9999|