最大匹配数就等于最大点覆盖,因为在图里面,凡是要覆盖的点必定是连通的,而最大匹配之后,若还有点没有覆盖到,则必定有新的匹配,与最大匹配数矛盾,如果去掉一些匹配,则必定有点没有覆盖到. POJ 1469 比较简单,用的经典的二分图匹配算法. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int p[500][5…
题意:有两台机器,上面有多个工作区域,有多个任务,分别可以在两台机器的某一个区域上完成,两台机器一开始都在0区域上工作,每次更改区域,都会重新启动一次,让我们求出最小的重启次数. 思路:将两个区域连线,使用二分图,求出最大匹配数,容易想明白,正好就是最小重启的次数. 注意:0一开始就已经完成,不应该加入到匹配序列. 代码如下: #include<iostream> #include<algorithm> #include<queue> #include<cstdi…
点击打开链接 Konig定理:二分图的最小顶点覆盖数 = 二分图的最大匹配数 题意: 在N*N的网络中有K颗小行星.小行星i的位置是(Ri, Ci).如今有一个强力的武器可以用一发光束将一整行或一整列的小行星消灭.想要利用这个武器消灭全部的小行星最少须要几发光束? 分析: 以小行星的左右坐标建立二分图,就能够看出是求二分图的最小顶点覆盖数. #include <cstdio> #include <cstring> #include <vector> #include &…
Girls and Boys Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 10132    Accepted Submission(s): 4660 Problem Description the second year of the university somebody started a study on the roman…
题目描述: Professor Clumsey is going to give an important talk this afternoon. Unfortunately, he is not a very tidy person and has put all his transparencies on one big heap. Before giving the talk, he has to sort the slides. Being a kind of minimalist,…
地址  https://www.acwing.com/problem/content/description/863/ 给定一个二分图,其中左半部包含n1n1个点(编号1~n1n1),右半部包含n2n2个点(编号1~n2n2),二分图共包含m条边. 数据保证任意一条边的两个端点都不可能在同一部分中. 请你求出二分图的最大匹配数. 二分图的匹配:给定一个二分图G,在G的一个子图M中,M的边集{E}中的任意两条边都不依附于同一个顶点,则称M是一个匹配. 二分图的最大匹配:所有匹配中包含边数最多的一组…
COURSES Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 24192   Accepted: 9426 Description Consider a group of N students and P courses. Each student visits zero, one or more than one courses. Your task is to determine whether it is poss…
两题二分图匹配的题: 1.一个农民有n头牛和m个畜栏,对于每个畜栏,每头牛有不同喜好,有的想去,有的不想,对于给定的喜好表,你需要求出最大可以满足多少头牛的需求. 2.给你学生数和课程数,以及学生上的课,如果可以做到每个学生代表不同的课程并且所有的课程都被代表输出"YES"(学生能代表一门课当且仅当他上过). 1.POJ 1274 The Perfect Stall http://poj.org/problem?id=1274 和上一题过山车一样,也是二分图匹配的. 水题. #incl…
原题 本题为最小点覆盖,而最小点覆盖=最大二分图匹配 //最小点覆盖:用最少的点(左右两边集合的点)让每条边都至少和其中一个点关联. #include<cstdio> #include<cstring> #define N 510 using namespace std; int edge[N][N],n,m,lover[N],ans; bool vis[N]; bool find(int x) { for (int i=1;i<=n;i++) if (edge[x][i]…
这道题让我认识到了c++cin,cout确实会使其超时,还是我用的c printf吧 #include<cstdio> #include<iostream> #include<cstring> #include<algorithm> #include<climits> using namespace std; #define MAX 5005 int p,n; int V1,V2; ][]; ]; ]; int m; //最大匹配数 bool d…