图论

图论--网络流--最大流 HDU 3572 Task Schedule(限流建图,超级源汇)

这一生的挚爱 提交于 2019-11-26 18:26:08
Problem Description Our geometry princess XMM has stoped her study in computational geometry to concentrate on her newly opened factory. Her factory has introduced M new machines in order to process the coming N tasks. For the i-th task, the factory has to start processing it at or after day Si, process it for Pi days, and finish the task before or at day Ei. A machine can only work on one task at a time, and each task can be processed by at most one machine at a time. However, a task can be interrupted and processed on different machines on different days. Now she wonders whether he has a

poj 1459 Power Network 【图论-网络流-最大流-EK】

。_饼干妹妹 提交于 2019-11-26 18:25:36
Power Network Time Limit: 2000MS Memory Limit: 32768K Description A power network consists of nodes (power stations, consumers and dispatchers) connected by power transport lines. A node u may be supplied with an amount s(u) >= 0 of power, may produce an amount 0 <= p(u) <= pmax(u) of power, may consume an amount 0 <= c(u) <= min(s(u),cmax(u)) of power, and may deliver an amount d(u)=s(u)+p(u)-c(u) of power. The following restrictions apply: c(u)=0 for any power station, p(u)=0 for any consumer, and p(u)=c(u)=0 for any dispatcher. There is at most one power transport line (u,v) from a node u

图论--网络流--最大流 HDU 2883 kebab(离散化)

南楼画角 提交于 2019-11-26 18:24:45
Problem Description Almost everyone likes kebabs nowadays (Here a kebab means pieces of meat grilled on a long thin stick). Have you, however, considered about the hardship of a kebab roaster while enjoying the delicious food? Well, here's a chance for you to help the poor roaster make sure whether he can deal with the following orders without dissatisfying the customers. Now N customers is coming. Customer i will arrive at time si (which means the roaster cannot serve customer i until time si). He/She will order ni kebabs, each one of which requires a total amount of ti unit time to get it

图论--网络流--最大流 洛谷P4722(hlpp)

筅森魡賤 提交于 2019-11-26 18:19:38
题目描述 给定 nn 个点,mm 条有向边,给定每条边的容量,求从点 ss 到点 tt 的最大流。 输入格式 第一行包含四个正整数nn、mm、ss、tt,用空格分隔,分别表示点的个数、有向边的个数、源点序号、汇点序号。 接下来mm行每行包含三个正整数u_iui​、v_ivi​、c_ici​,用空格分隔,表示第ii条有向边从u_iui​出发,到达v_ivi​,容量为c_ici​ 输出格式 一个整数,表示ss到tt的最大流 输入输出样例 输入 #1 7 14 1 7 1 2 5 1 3 6 1 4 5 2 3 2 2 5 3 3 2 2 3 4 3 3 5 3 3 6 7 4 6 5 5 6 1 6 5 1 5 7 8 6 7 7 输出 #1 14 输入 #2 10 16 1 2 1 3 2 1 4 2 5 2 2 6 2 2 3 5 1 3 6 1 4 5 1 4 6 1 1 7 2147483647 9 2 2147483647 7 8 2147483647 10 9 2147483647 8 5 2 8 6 2 3 10 2 4 10 2 输出 #2 8 //500ms 秒掉洛谷推流问题 #include <algorithm> #include <iostream> #include <cstring> #include <vector> #include <queue>

图论--网络流--费用流POJ 2195 Going Home

左心房为你撑大大i 提交于 2019-11-26 18:19:03
Description On a grid map there are n little men and n houses. In each unit time, every little man can move one unit step, either horizontally, or vertically, to an adjacent point. For each little man, you need to pay a $1 travel fee for every step he moves, until he enters a house. The task is complicated with the restriction that each house can accommodate only one little man. Your task is to compute the minimum amount of money you need to pay in order to send these n little men into those n different houses. The input is a map of the scenario, a '.' means an empty space, an 'H' represents a

图论--网络流--最大流--POJ 1698 Alice's Chance

好久不见. 提交于 2019-11-26 18:17:03
Description Alice, a charming girl, have been dreaming of being a movie star for long. Her chances will come now, for several filmmaking companies invite her to play the chief role in their new films. Unfortunately, all these companies will start making the films at the same time, and the greedy Alice doesn't want to miss any of them!! You are asked to tell her whether she can act in all the films. As for a film, it will be made ONLY on some fixed days in a week, i.e., Alice can only work for the film on these days; Alice should work for it at least for specified number of days; the film MUST

图论--网络流--费用流--POJ 2156 Minimum Cost

ⅰ亾dé卋堺 提交于 2019-11-26 18:16:39
Description Dearboy, a goods victualer, now comes to a big problem, and he needs your help. In his sale area there are N shopkeepers (marked from 1 to N) which stocks goods from him.Dearboy has M supply places (marked from 1 to M), each provides K different kinds of goods (marked from 1 to K). Once shopkeepers order goods, Dearboy should arrange which supply place provide how much amount of goods to shopkeepers to cut down the total cost of transport. It's known that the cost to transport one unit goods for different kinds from different supply places to different shopkeepers may be different.

图论--网络流最大流问题

北城以北 提交于 2019-11-26 18:15:52
问题表述: 给定一幅图(n个结点,m条边),每一条边有一个容量,现在需要将一些物品从结点s(称为源点)运送到结点t(称为汇点),可以从其他结点中转,求最大的运送量。 在介绍最大流问题的解决方法之前,先介绍几个概念. 网络 :网络是一个有向带权图,包含一个源点和一个汇点,没有反向平行边。 网络流 :网络流即网上的流,是定义在网络边集E上的一个非负函数flow={flow(u,v)}, flow(u,v)是边上的流量。 可行流 :满足以下两个性质的网络流flow称为可行流。 容量约束 :每条边的实际流量不能超过改变的最大流量。 流量守恒 :除了源点s和汇点t之外,所有内部节点流入量等于流出量。 源点s :源点主要是流出,但也有可能流入。 源点的净输出值=流出量之和-流入量之和。 汇点t :汇点主要是流入,但也有可能流出。 汇点的净输入值=流入量之和-流出量之和。 对于一个网络可行流flow,净输出等于净输入,这仍然是流量守恒。 网络最大流 :在满足容量约束和流量守恒的前提下,在流网络中找到一个净输出最大的网络流。 反向弧: 若从u到v的边的 容量 为c ,这条边上有流量 f 流过(称为正向弧),则相当于v到u有一条容量为0的边,其流量为- f ,这条边就是反向弧。反向弧的作用主要是用于寻找增广路。 反向弧的意义: 反向弧的作用是起到有更优 决策 的时候会使当前选择的弧会自动放弃

图论--最小费用最大流(MCMF)

断了今生、忘了曾经 提交于 2019-11-26 18:12:31
以下为提高+难度。 关于这个算法我不多做阐述,因为我说的肯定没有lrj大神说得好,大家可以看他的书–《算法竞赛入门经典》,那里有详细描述。 到了这种难度,极其建议大家去抄抄代码,过一遍手,比什么都强。 我也是这一遍抄完了,才感觉这两天的网络流明白了。 下来就是代码。 code: //洛谷 P3381 【模板】最小费用最大流 #include<bits/stdc++.h> #define ll long long using namespace std ; const int maxn= 10001 ,inf= 0x3f3f3f3f ; struct edge{ int from,to,cap,flow,cost; edge( int u, int v, int c, int f, int d):from(u),to(v),cap(c),flow(f),cost(d){} }; struct MCMF{ int n,s,t; ll cost,flow; vector <edge> edges; vector < int > G[maxn]; int a[maxn],p[maxn],d[maxn],in[maxn]; void init( int n, int s, int t){ this ->n=n; this ->s=s; this ->t=t; flow= 0 ; cost=

模板整理: 图论---网络流/最小费用最大流

不羁岁月 提交于 2019-11-26 18:10:55
NOIp……应该不会考这东西吧QAQ 考了感觉药丸。。 还是整一个比较好~ 网络流有个特点就是,最坏的上界一般都是达不到的。 1.FF 思路是每次增广1的流量,很慢的,因为容量一般挺大, 没写过,就没模板了。。O( | f | ∗ m //--> )(似乎是,有点忘了) 2.EK 思路是随意找一条增广路径,然后增广即可。 最坏O( m 2 n //--> )。 就写过一次……还是早期写的……真是有点丑的。。 bool EdKa( int src, int des, int n) { int v,i,head,tail; memset (visit, 0 , sizeof (visit)); head=tail= 0 ; Q[tail++]=src; visit[src]= true ; while (head!=tail) { v=Q[head++]; for (i= 1 ;i<=n;i++) if (!visit[i] && map [v][i]) { Q[tail++]=i; visit[i]= true ; pre[i]=v; if (i==des) return true ; } } return false ; } int maxflow( int src, int des, int n) { int i,_min,sum= 0 ; while ( true ) { if