随笔分类 - *图论---二分图
摘要:题目链接:here 题解: BFS+二分图最大匹配。这题的入手点就是休息点的个数比较小,最多52个。首先对每个休息点跑一遍BFS,记录休息点到每个点的最短距离。判断某个金矿是否在两个休息点之间可以被采集到:例如判断某金矿与BC路径,如果这个金矿与B的最短距离加上这个金矿与C的最短距离等于B与C的最短
阅读全文
摘要:Chocolate HDU - 2282 题意:初始n块巧克力不均匀的放到n个盒子(环形)里,每次可以移动一块巧克力,问最少多少步使得每个盒子里有一块巧克力。 1 #include <bits/stdc++.h> 2 using namespace std; 3 const int maxv=510
阅读全文
摘要:Special Fish HDU - 3395 题意:n条鱼,被攻击后会产卵,如果i攻击j,那么后代会有g[i]^g[j]的值,求所有后代和的最大值。 KM 1 #include <bits/stdc++.h> 2 using namespace std; 3 const int inf=0x3f3
阅读全文
摘要:Interesting Housing Problem HDU - 2426 题意:n个人,m个房间,安排住宿。要求每个人不能分到不喜欢的房间,且使满意度最大。 不用slack几乎要超时~ 1 #include <bits/stdc++.h> 2 using namespace std; 3 con
阅读全文
摘要:Going Home HDU - 1533 题意:给出地图,其中m和h个数相等,求所有m到h的总路程最短。 KM 1 #include <bits/stdc++.h> 2 using namespace std; 3 const int inf=0x3f3f3f3f; 4 const int max
阅读全文
摘要:奔小康赚大钱 HDU - 2255 题意:给出每个村民愿意为每个房子出的价钱,问怎么分配房子可以使收益最大。 KM算法 一直对slack数组有点迷~ 1 #include <bits/stdc++.h> 2 using namespace std; 3 const int inf=0x3f3f3f3
阅读全文
摘要:SAM I AM UVA - 11419 二分图最小覆盖 二分图的最小顶点覆盖数等于最大匹配数。 且选择的顶点为: 从左边未被匹配的点开始扩展匈牙利树,标记树中的所有节点,取左边未被标记的和右边被标记的。 1 #include <bits/stdc++.h> 2 using namespace st
阅读全文
摘要:Ladies' Choice UVALive - 3989 大白书p352 1 #include <bits/stdc++.h> 2 using namespace std; 3 const int maxn=1010; 4 int pref[maxn][maxn],order[maxn][maxn
阅读全文
摘要:update(2018-01-20): 发现暑假的时候真是zz。。。 学了好久也不是很理解,今天一下就看懂了。。。 之前还以为不用slack的方法更快,理解了之后发现没用slack数组的写法都是错的orz。。。很巧合的过了一些题。。。zz Ants UVALive - 4043 这题真是心态崩了 一
阅读全文

浙公网安备 33010602011771号