• <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 付翔 閱讀(936) 評論(0)  編輯 收藏 引用

            <2011年5月>
            24252627282930
            1234567
            891011121314
            15161718192021
            22232425262728
            2930311234

            常用鏈接

            留言簿(2)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            CSDN - 我的blog地址

            博客

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            久久精品国产72国产精福利| 午夜精品久久影院蜜桃| 亚洲精品国产字幕久久不卡| 久久精品麻豆日日躁夜夜躁| 久久e热在这里只有国产中文精品99| 伊人久久综在合线亚洲2019| 天天躁日日躁狠狠久久| 亚洲精品国产字幕久久不卡| 少妇熟女久久综合网色欲| 久久久久亚洲AV片无码下载蜜桃| 亚洲国产成人久久一区久久| 久久91精品综合国产首页| 一本久道久久综合狠狠爱| 久久人人爽人人澡人人高潮AV | 国产V综合V亚洲欧美久久 | 亚洲国产精品无码久久久不卡| 亚洲AV成人无码久久精品老人| 一本一道久久综合狠狠老| 无码八A片人妻少妇久久| 国产毛片久久久久久国产毛片 | 亚洲精品tv久久久久久久久久| 一本一道久久精品综合| 久久九色综合九色99伊人| 久久久久亚洲精品中文字幕| 久久精品国产色蜜蜜麻豆| 久久久久亚洲精品无码网址 | 精品永久久福利一区二区| www.久久99| 久久福利片| 伊人久久大香线蕉亚洲| 亚洲乱码精品久久久久.. | 欧美精品丝袜久久久中文字幕 | 狠狠色丁香婷婷久久综合| 伊人久久综合精品无码AV专区| 欧美激情精品久久久久久久| 亚洲中文字幕无码久久精品1| 国产精品一区二区久久国产| 9999国产精品欧美久久久久久| 久久996热精品xxxx| 97精品依人久久久大香线蕉97| 亚洲日本va午夜中文字幕久久 |