题意:有一个N个点的有向带权图,要求找若干个有向圈,使得每个点恰好属于一个圈.请输出满足以上条件的最小权和. 解法:有向圈?也就是每个点有唯一的后继.这是一个可逆命题,同样地,只要每个点都有唯一的后继,那么它们一定恰好属于一个圈.而"唯一"可以想到二分图匹配.把每个点拆成两个点,分别放在二分图的两边.两侧的点连的边就是原来的边的转化,另外再给源点和汇点分别连 n 条容量为1.费用为0的边.这样就保证了每个点有唯一的后继.再由于是要求所有点都属于一个圈,也就是完美匹配,就判断一下是否满流…
UVa 1045 - The Great Wall Game 最小权匹配 题意:给你一个n*n的棋盘,上面有n个棋子,要求通过移动各个棋子使得棋子在同一行或者同一列或者对角线上,求最小移动次数. 思路:直接对于所有可能情况构造二分图,X集合为最初棋子,Y集合为移动后的棋子方位,边权为移动的次数.然后KM算法求最小权匹配. /* ********************************************** Author : JayYe Created Time: 2013-8-18…
POJ 2289 Jamie's Contact Groups / UVA 1345 Jamie's Contact Groups / ZOJ 2399 Jamie's Contact Groups / HDU 1699 Jamie's Contact Groups / SCU 1996 Jamie's Contact Groups (二分,二分图匹配) Description Jamie is a very popular girl and has quite a lot of friends…
uva 12083 Guardian of Decency Description Frank N. Stein is a very conservative high-school teacher. He wants to take some of his students on an excursion, but he is afraid that some of them might become couples. While you can never exclude this poss…