第一题:按顾客访问猪圈的顺序依次构图(顾客为结点),汇点->第一个顾客->第二个顾客->...->汇点 //第一道网络流 //Ford-Fulkerson //Time:47Ms Memory:276K #include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #include<queue> using namespace std;…
http://hihocoder.com/problemset/problem/1369?sid=1328132 参考 https://blog.csdn.net/a1799342217/article/details/73195243 https://blog.csdn.net/a519781181/article/details/51908303 [AC1] #include<iostream> #include<cstdio> #include<cstring>…
Hihocoder 太阁最新面经算法竞赛18 source: https://hihocoder.com/contest/hihointerview27/problems 题目1 : Big Plus 描述 Given an NxN 01 matrix, find the biggest plus (+) consisting of 1s in the matrix. size 1 plus size 2 plus size 3 plus size 4 plus 1 1 1 1 111 1 1…
hihoCoder太阁最新面经算法竞赛15 Link: http://hihocoder.com/contest/hihointerview24 题目1 : Boarding Passes 时间限制:10000ms 单点时限:1000ms 内存限制:256MB   描述 Long long ago you took a crazy trip around the world. You can not remember which cities did you start and finish t…
网络流-最大流问题 ISAP 算法解释 August 7, 2013 / 编程指南 ISAP 是图论求最大流的算法之一,它很好的平衡了运行时间和程序复杂度之间的关系,因此非常常用. 约定 我们使用邻接表来表示图,表示方法可以见文章带权最短路 Dijkstra, SPFA, Bellman-Ford, ASP, Floyd-Warshall 算法分析或二分图的最大匹配.完美匹配和匈牙利算法的开头(就不重复贴代码了).在下文中,图的源点(source)表示为 s ,汇点(sink)表示为 t ,当前…
题目链接. 分析: 网络流增广路算法模板题.http://www.cnblogs.com/tanhehe/p/3234248.html AC代码: #include <iostream> #include <queue> #include <cstdio> #include <cstring> using namespace std; ; <<); int cap[maxn][maxn], flow[maxn][maxn]; int n; int…
Test链接:https://cn.vjudge.net/contest/231849 选自hihoCoder太阁最新面经算法竞赛1 更多Test:传送门 A:区间求差 给一组区间集合A和区间集合B,求A-B的长度 思路: 首先进行离散化,对每个点进行标号处理,对于A中的每个区间,用树状数组把离散化后的A中的每个区域标记. 对于B的每个区间,用另一个树状数组标记. 这里对点i标记,等价于标记线段[i-1, i](i为离散化后的标号) 之后对每个点查询是否在A中标记,在B中未标记,那就是A-B的子…
[Link]:http://hihocoder.com/problemset/problem/1369 [Description] [Solution] 最大流模板题 [NumberOf WA] [Reviw] [Code] #include <bits/stdc++.h> using namespace std; #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 #define LL long long #define…
http://hihocoder.com/problemset/problem/1369?sid=1108721 别人都说先学网络流再学二分图,但是我先学了二分图的,感觉网络流好高端啊. 首先对于原图,e[u][v],找到一条路径从be --> en后,要更新残余网络. 什么意思,其他东西自己百度.其实就是建反向边. 比如: 1 --> 2   w = 1 1 --> 3   w = 1 2 --> 3   w = 1 2 --> 4   w = 1 3 --> 4  …
#1393 : 网络流三·二分图多重匹配 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 学校的秋季运动会即将开始,为了决定参赛人员,各个班又开始忙碌起来. 小Hi和小Ho作为班上的班干部,统计分配比赛选手的重任也自然交到了他们手上. 已知小Hi和小Ho所在的班级一共有N名学生(包含小Hi和小Ho),编号依次为1..N. 运动会一共有M项不同的比赛,编号为1..M.第i项比赛每个班需要派出m[i]名选手参加. 根据小Hi和小Ho的统计,编号为i的学生表示最多同时参加…