hdu 2389(二分图hk算法模板)】的更多相关文章

Rain on your Parade Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 655350/165535 K (Java/Others)Total Submission(s): 3675    Accepted Submission(s): 1187 Problem Description You’re giving a party in the garden of your villa by the sea. The p…
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1083 Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Description Consider a group of N students and P courses. Each student visits zero, one or more than…
链接:http://acm.hdu.edu.cn/showproblem.php?pid=2586 题意:n个村庄构成一棵无根树,q次询问,求任意两个村庄之间的最短距离 思路:求出两个村庄的LCA,dis[ i ] 表示结点 i 到树根的距离,那么任意两点u,v的最短距离就是dis[ u ]  - dis [LCA] + dis [ v ] - dis[ LCA ].代码是用tarjan做的,算是模板,记录一下. AC代码: #include<iostream> #include<cst…
题目大意: 给定每一个人能支付的房子价值,每个人最多且必须拥有一套房子,问最后分配房子可得到的最大收益 抄了个别人的KM模板,就这样了... #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define N 305 const int INF = 0x7fffffff; int n , nx , ny; in…
题目:http://poj.org/problem?id=1325 求最小点覆盖.输出最大匹配数就行,结果略复杂地弄了. 注意由题可知 可以直接把与0有关的边删掉.不过亲测不删0而计数时不计0就会WA. #include<iostream> #include<cstdio> #include<cstring> using namespace std; ],head[],xnt,a,x,y,ans; ]; struct Node{ int next,to; }edge[]…
HUST 2604 #include <iostream> #include <cstdlib> #include <cstdio> #include <cstring> #include <queue> #include <cmath> using namespace std; const int N = 300010; const int MAXM = 300010; const int INF = 0x3f3f3f3f; int…
<题目链接> 题目大意:有m个宾客,n把雨伞,预计时间t后将会下大雨,告诉你每个宾客的位置和速度,每把雨伞的位置,问你最多几个宾客能够拿到伞. 解题分析: 本题就是要我们求人与伞之间的最大匹配,但是数据量较大,匈牙利算法复杂度为$O(n*m)$,会超时,所以这里用的是复杂度为$O(sqrt(n)*m)$的HK算法. 当然,本题也可以用Dinic最大流来求解最大匹配,并且这种方法求得到最大匹配的时间复杂度也为$O(sqrt(n)*m)$ #include <bits/stdc++.h>…
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5727 Problem DescriptionSJX has 2*N magic gems. N of them have Yin energy inside while others have Yang energy. SJX wants to make a necklace with these magic gems for his beloved BHB. To avoid maki…
HDU 2389 Rain on your Parade / HUST 1164 4 Rain on your Parade(二分图的最大匹配) Description You're giving a party in the garden of your villa by the sea. The party is a huge success, and everyone is here. It's a warm, sunny evening, and a soothing wind send…
二分图:https://blog.csdn.net/c20180630/article/details/70175814 https://blog.csdn.net/flynn_curry/article/details/52966283 匈牙利算法模板:https://blog.csdn.net/sunny_hun/article/details/80627351 例题:hdu 1150 Machine Schedule 参考:https://www.cnblogs.com/qq-star/p…