//匈牙利算法-DFS //求最小点覆盖集 == 求最大匹配 //Time:0Ms Memory:208K #include<iostream> #include<cstring> #include<cstdio> #include<algorithm> using namespace std; #define MAX 105 #define INF 0x3f3f3f3f int n,m,k; int gp[MAX][MAX]; bool sx[MAX],s…
Machine Schedule As we all know, machine scheduling is a very classical problem in computer science and has been studied for a very long history. Scheduling problems differ widely in the nature of the constraints that must be satisfied and the type o…
匈牙利算法 简介 匈牙利算法是一种求二分图最大匹配的算法. 时间复杂度: 邻接表/前向星: \(O(n * m)\), 邻接矩阵: \(O(n^3)\). 空间复杂度: 邻接表/前向星: \(O(n + m)\), 邻接矩阵: \(O(n^2)\). 它的主要思路就是对每个点寻找增广路, 尝试改变之前的选择, 判断是否可行. 事实上, 利用dinic/isap跑二分图有 \(O(n * \sqrt{m})\) 的优秀复杂度(不会证), 因此匈牙利算法仅用于少数特殊情况↓ 代码 int to[ns…
按照电站发电(从源点到电站),消费者消费(从消费者到汇点)的想法构建网络,以下是EK解法 //网络流EK算法 //Time:922Ms memory:224K #include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #include<queue> using namespace std; #define MAX 105 #define INF 0x3f3f…
基于残留网络与FF算法的改进-EK算法,核心是将一条边的单向残留容量的减少看做反向残留流量的增加. //网络流 //EK算法 //Time:16Ms Memory:348K #include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #include<queue> using namespace std; #define MAX 205 #define INF…
Weak Pair Problem Description   You are given a rooted tree of N nodes, labeled from 1 to N. To the ith node a non-negative value ai is assigned.An ordered pair of nodes (u,v) is said to be weak if  (1) u is an ancestor of v (Note: In this problem a…
Strategic Game Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6421    Accepted Submission(s): 2987 Problem Description Bob enjoys playing computer games, especially strategic games, but somet…
原题链接:K-Link-Cut Tree_第46屆ICPC 東亞洲區域賽(澳門)(正式賽) (nowcoder.com) 题意: 要求一个边权值总和最小的环,并从小到大输出边权值(2的次幂):若不存在环,输出-1. 思路: 考虑按权值从小到大加边,当出现环时(利用并查集判环),这个环必定是总权值最小的环. 找到环后,不再加边,并从环上某一点做DFS,找到从该点出发并再次回到该点的环. 代码: #include <bits/stdc++.h> #define PII pair<int,in…
匈牙利算法(二分图最大匹配)- hdu 过山车 Hdu 2063 二分图:图中的点可以分成两组U,V,所有边都是连接U,V中的顶点.等价定义是:含奇数条边的图. 匹配:一个匹配是一个边的集合,其中任意两条边都没有公共顶点(每个顶点只连出一条边).随便找几条边,只要边没有公共顶点,就能构成匹配 最大匹配:含边数最多的匹配 完美匹配:一个匹配包含了图中的所有顶点.完美匹配都是最大匹配(所有点都连了边,无法再添加任何一条边,故为最大匹配).不是每个图都存在完美匹配 举个栗子:考虑男女配对的问题,边表示…
1022 覆盖    时间限制: 1 s  空间限制: 128000 KB  题目等级 : 大师 Master 题解  查看运行结果     题目描述 Description 有一个N×M的单位方格中,其中有些方格是水塘,其他方格是陆地.如果要用1×2的矩阵区覆盖(覆盖过程不容许有任何部分重叠)这个陆地,那么最多可以覆盖多少陆地面积. 输入描述 Input Description 输入文件的第一行是两个整数N,M  (1<=N,M<=100),第二行为一个整数K( K<=50),接下来的…