摘要:        
题意: 给你 n 个机器,m 头牛,每台机器最多可供 cap 头牛使用,并告诉你每个物体之间的距离,找出一个距离满足所有的牛都分配到机器且里面走最远的牛 走的距离最小。分析: 用 floyd 计算出每个物体的最短距离,然后二分枚举距离,如果在该距离下满足完全匹配,该距离即为合法距离,匹配用到多重匹配。二分图多重匹配 #include<stdio.h>#include<string.h>#define clr(x)memset(x,0,sizeof(x))int cap;int link[33][202];int vlink[33];int v[33];struct no    阅读全文
        
            posted @ 2012-04-22 13:05
'wind
阅读(243)
评论(0)
推荐(0)
        
        
            
        
        
摘要:        
题意: 有 n 牛, m 个 房子, 每个牛都只住在自己想住的房子里面,一个房子只能住一个牛,问最多可以安排多少头牛入住。分析: 求最大匹配。View Code #include<stdio.h>#include<string.h>#define clr(x)memset(x,0,sizeof(x))struct node{ int to,next;}q[40005];int tot;int head[202];void add(int s,int u){ q[tot].to=u; q[tot].next=head[s]; head[s]=tot++;}int link    阅读全文
        
            posted @ 2012-04-22 10:58
'wind
阅读(159)
评论(0)
推荐(0)
        
        
            
        
        
摘要:        
题意: 给你N 个球,如果两个球球有重叠部分的话就称这两个球是联通的 ,如果两个球不想交,可以在他们之间建立一个桥梁,使其联通,问最少需要建多少长度的桥梁才能是全部的球联通。分析: 图建好后就是最小生成树问题。View Code #include<stdio.h>#include<string.h>#include<stdlib.h>#include<math.h>int u[5005],v[5005],f[103],r[5005];double w[5005];int cmp(const void*p1,const void*p2){ retu    阅读全文
        
            posted @ 2012-04-22 10:36
'wind
阅读(163)
评论(0)
推荐(0)
        
        
            
        
        
摘要:        
题意:给你n 个学生 p 个课程,每一个课程都有一定的学生会选,能否找出p 个学生使他们满足每个学生选的课都不同。分析:看看能否找到一个完全匹配的二分图。View Code #include<stdio.h>#include<string.h>#define clr(x)memset(x,0,sizeof(x))struct node{ int to,next;}q[100000];int head[103];int tot;void add(int s,int u){ q[tot].to=u; q[tot].next=head[s]; head[s]=tot++;}i    阅读全文
        
            posted @ 2012-04-22 09:55
'wind
阅读(135)
评论(0)
推荐(0)
        
        
            
        
        
摘要:        
题意: 两台机器,有 k 个工作,每个工作可以在 a 机器的 P模式或在 b 机器的 q 模式下解决,两台机器初始状态为 0 模式,每台机器没变换一次模都要重启一次, 问至少重启多少次可以完成所有工作。分析: 构图方式 if(x*y!=0) g[x][y]=1; 求出最小点覆盖,即找到最少的点来覆盖所有的边。View Code #include<stdio.h>#include<string.h>#define clr(x)memset(x,0,sizeof(x))struct node{ int to,next;}q[100000];int head[102];int    阅读全文
        
            posted @ 2012-04-22 09:13
'wind
阅读(162)
评论(0)
推荐(0)
        
        
            
        
        
摘要:        
题意: 给你一些课程和他们的上课时间,求在不冲突的情况下最多能上几节课。分析: 裸的二分图。View Code #include<stdio.h>#include<string.h>#define clr(x)memset(x,0,sizeof(x))struct node{ int to,next;}q[10000000];int tot;int head[303];void add(int s,int u){ q[tot].to=u; q[tot].next=head[s]; head[s]=tot++;}int link[303];int v[100];int f    阅读全文
        
            posted @ 2012-04-22 08:20
'wind
阅读(212)
评论(0)
推荐(0)
        
        
 
                    
                     
                    
                 
                    
                

 
         浙公网安备 33010602011771号
浙公网安备 33010602011771号