HDU3549 最大流 裸题】的更多相关文章

EK算法 时间复杂度o(n*m*m)  因为有反向边每次bfs时间为 n*m 每次删一条边 最多m次 代码 #include<iostream> #include<string.h> #include<vector> #include<stdio.h> #include<queue> using namespace std; ,inf=0x3f3f3f3f; typedef long long ll; struct edge { int from…
最大流裸题,贴下模版 view code#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <vector> #include <queue> using namespace std; const int INF = 0x3f3f3f3f; const int maxn…
A Plug for UNIX Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 15597   Accepted: 5308 Description You are in charge of setting up the press room for the inaugural meeting of the United Nations Internet eXecutive (UNIX), which has an int…
1.HDU-3549   Flow Problem 2.链接:http://acm.hdu.edu.cn/showproblem.php?pid=3549 3.总结:模板题,参考了 http://www.cnblogs.com/Lyush/archive/2011/08/08/2130660.html  ,里面有几种模板,没太看懂 题意:给定有向图,求第1到第n个点的最大流. #include<iostream> #include<cstring> #include<cmat…
题意: 1.一个人从[1,1] ->[n,n] ->[1,1] 2.仅仅能走最短路 3.走过的点不能再走 问最大和. 对每一个点拆点限流为1就可以满足3. 费用流流量为2满足1 最大费用流,先给图取负,结果再取负,满足2 #include <stdio.h> #include <string.h> #include <iostream> #include <math.h> #include <queue> #include <s…
注意这道题是双向边, 然后直接套模板就ok了. #include<cstdio> #include<algorithm> #include<vector> #include<queue> #include<cstring> #define REP(i, a, b) for(int i = (a); i < (b); i++) using namespace std; const int MAXN = 112; struct Edge { i…
给出一个n*m的图,其中m是人,H是房子,.是空地,满足人的个数等于房子数. 现在让每个人都选择一个房子住,每个人只能住一间,每一间只能住一个人. 每个人可以向4个方向移动,每移动一步需要1$,问所有人移动到房子里的最少花费. 其中,n,m<=100,最多有100个人. 最小给用流裸题. 建立一个超级源点,跟每一个房子连一条边,容量为1,花费为0 每一个人与超级汇点连一条边,容量为1,花费为0 一个房子与每一个人建一条边,房子指向人,容量为1,花费用2者的距离(不是直线距离) 然后跑最小费用流算…
人生第一道splay不出所料是一道裸题,一道水题,一道2k代码都不到的题 #include <cstdio> ,n,p,q; ],c[][],size[],sp[]; void rot(int x) { ]==x); size[y]=size[c[y][k]]+size[c[x][k]]+;size[x]=size[c[x][!k]]+size[y]+; c[y][!k]=c[x][k];fa[c[y][!k]]=y; fa[x]=fa[y];]==y]=x; c[x][k]=y;fa[y]=…
主要借助这道比较裸的题来讲一下tarjan这种算法 tarjan是一种求解有向图强连通分量的线性时间的算法.(用dfs来实现) 如果两个顶点可以相互通达,则称两个顶点强连通.如果有向图G的每两个顶点都强连通,称G是一个强连通图.有向图的极大强连通子图,称为强连通分量. 在上面这张有向图中1,2,3,4形成了一个强连通分量,而1,2,4,和1,3,4并不是(因为它们并不是极大强连通子图). tarjan是用dfs来实现的(用了tarjan后我们就可以对图进行缩点(当然这道裸题用不到)) 这道题只要…
①洞穴勘测 bzoj2049 题意:由若干个操作,每次加入/删除两点间的一条边,询问某两点是否连通.保证任意时刻图都是一个森林.(两点之间至多只有一条路径) 这就是个link+cut+find root的裸题啦. LCT实现的时候注意在splay的时候要提前把所有点pushdown一下,详见代码. #include <iostream> #include <stdio.h> #include <stdlib.h> #include <algorithm> #…