hdu1532 输入n,m. n条边,m个点,之后给出a到b的容量,求1到m的最大流. 注意:Dinic只能调用一次,因为原理是改变cap的值,如果调用多次一样的,那么第一次会对,其余的都会是0,因为,cap的值经过一次调用已经改变了,如果想调用多次,就只能再开一个数组,存下原来的cap值. #include <bits/stdc++.h> using namespace std; const int INF=0x3f3f3f3f; typedef long long LL; #define…
ISAP // UVa11248 Frequency Hopping:使用ISAP算法,加优化 // Rujia Liu struct Edge { int from, to, cap, flow; }; struct ISAP { int n, m, s, t; vector<Edge> edges; vector<int> G[maxn]; // 邻接表,G[i][j]表示结点i的第j条边在e数组中的序号 bool vis[maxn]; // BFS使用 int d[maxn]…
Description Every time it rains on Farmer John's fields, a pond forms over Bessie's favorite clover patch. This means that the clover is covered by water for awhile and takes quite a long time to regrow. Thus, Farmer John has built a set of drainage…
Drainage Ditches Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 8599 Accepted Submission(s): 4005 Problem Description Every time it rains on Farmer John's fields, a pond forms over Bessie's…
Power Network Time Limit: 2000MS Memory Limit: 32768K Total Submissions: 25832 Accepted: 13481 Description A power network consists of nodes (power stations, consumers and dispatchers) connected by power transport lines. A node u may be supplied…
#include<cstring> #include<cstdio> #define FOR(i,f_start,f_end) for(int i=f_startl;i<=f_end;i++) #define MS(arr,arr_value) memset(arr,arr_value,sizeof(arr)) ; ; int size; int n; const int inf=0x3f3f3f3f; using namespace std; int head[maxn];…
#include <iostream> #include <cstdio> #include <cstring> #include <queue> #define mem(a,b) memset(a,b,sizeof(a)) using namespace std; , INF = 0x7fffffff; int d[maxn], head[maxn]; int n, m, s, t; struct edge{ int u, v, f, c, next; }…
//这个是邻接矩阵的#include<iostream> #include<queue> #include<string.h> #include<stdio.h> #include<algorithm> using namespace std; ; const int inf=0x3f3f3f; int N; int depth[maxn]; int a[maxn][maxn]; bool bfs(int s,int e)//广搜求深度 { qu…
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; int n, m, S, T; ;//点数的最大值 ;//边数的最大值 const int INF = 0x3f3f3f3f; struct Edge { int to,next,cap,flow; } edge[MAXM]; //注意是MAXM int tol; int head[MAXN]; void init()…
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…