记得把数组开大一点,不然就RE了... 1 #include<bits/stdc++.h> 2 using namespace std; 3 #define int long long 4 const int N=5e5; 5 const int M=5e5; 6 const int INF=0x3f3f3f3f; 7 8 int n,m,s,t,ans,d[N],maxflow; 9 int tot=1,adj[N],nex[M],to[M],cap[M],cost[M]; 10 bool…
EK + dijkstra (2246ms) 开氧气(586ms) dijkstra的势 可以处理负权 https://www.luogu.org/blog/28007/solution-p3381 #include <bits/stdc++.h> using namespace std; const int INF = 1e9; int n, m, s, t, cnt; struct node { int to, nex, val, cost; }E[100005]; int head[5…
s向仓库i连ins(s,i,a[i],0),商店向t连ins(i+m,t,b[i],0),商店和仓库之间连ins(i,j+m,inf,c[i][j]).建两次图分别跑最小费用最大流和最大费用最大流即可. #include<iostream> #include<cstdio> #include<queue> #include<cstring> using namespace std; const int N=1000005,inf=1e9; int n,m,h…
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=693 题意:有一个 k 核的处理器和 n 个工作,全部的工作都须要在一个核上处理一个单位的时间,每一个核在不同一时候间处理同一个工作的花费是递增的,每一个核一次仅仅能处理一个工作,求运用k个核处理这n个工作的最小花费. 分析: 分析可知,求处理全部工作的最小花费,而每次选择怎么处理我们能够通过容量都为1的边来让网络流处理,这样就转化为最小费用最大流. 首先设一个超级源点s,连接全部的工作…
图论算法-最小费用最大流模板[EK;Dinic] EK模板 const int inf=1000000000; int n,m,s,t; struct node{int v,w,c;}; vector<node> map[10010]; int flow[10010][10010]; bool inq[10010]; int d[10010]; int pre[10010],pref[10010]; int minc,maxf; int main() { cin>>n>>…
Matrix Again Time Limit: 5000/2000 MS (Java/Others) Memory Limit: 102400/102400 K (Java/Others)Total Submission(s): 4255 Accepted Submission(s): 1233 Problem Description Starvae very like play a number game in the n*n Matrix. A positive integer…
Farm Tour Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 13509 Accepted: 5125 Description When FJ's friends visit him on the farm, he likes to show them around. His farm comprises N (1 <= N <= 1000) fields numbered 1..N, the first of…