自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(19)
  • 收藏
  • 关注

原创 hdu 3061 Battle 最大权闭合图

#include #include #include #include using namespace std;#define maxn 1000#define INF 100000struct Edge{ int from, to, cap, flow;};int n, m, s, t;vector edges; // 边数的两倍vector G[maxn];

2014-03-31 13:04:34 426

原创 hdu 3452 Bonsai 最小割

#include #include #include #include using namespace std;#define maxn 1500#define INF 100000struct Edge{ int from, to, cap, flow;};int n, m, s, t;vector edges; // 边数的两倍vector G[maxn

2014-03-29 16:14:13 418

原创 poj 1637 Sightseeing tour 混合欧拉 最大流

#include #include #include #include using namespace std;#define maxn 230#define INF 100000struct Edge{ int from, to, cap, flow;};int n, m, s, t;vector edges; // 边数的两倍vector G[maxn];

2014-03-29 16:12:18 421

原创 hdu 2473 Junk-Mail Filter 并查集

#include #include #define maxn 1001000int id[maxn],p[maxn];bool vis[maxn];int find(int x){ if(p[x]==x) return x; else return p[x]=find(p[x]);}void link(int a,int b){ int x=find(a)

2014-03-28 21:18:44 380

原创 hdu 3046 Pleasant sheep and big big wolf 网络流

原图中相邻点两两连边,容量为1,源点连接狼的节点,容量为INF,羊的节点连接汇点,容量为INF,这样求最小割就可以了。#include #include #include #include using namespace std;#define maxn 50000#define INF 100000struct Edge{ int from, to, cap, flo

2014-03-27 12:52:01 512

原创 hdu 3998 Sequence 网络流

题意:求一个序列最长上升子序列的长度以及有多少个最长上升子序列。#include #include #include #include using namespace std;#define maxn 10000#define INF 100000struct Edge{ int from, to, cap, flow;};int s, t;int num;i

2014-03-26 13:36:15 403

原创 hdu 4240 Route Redundancy 网络流

题意:在一个网络中求最大流和一条流量最大的路的流量的比值。主要是求最大流量的路,深搜一遍,数组q[ i ]表示从s到i点的最大流量,不断更新即可。#include #include #include #include using namespace std;#define maxn 1500#define INF 10000000struct Edge{ int f

2014-03-26 12:52:50 546

原创 hdu 3667 Transportation 费用流

#include #include #include using namespace std;const int N=500;const int MAXE=20000000;const int inf=1<<30;int head[N],s,t,cnt,n,m,ans,k;int d[N],pre[N];bool vis[N];int q[MAXE];int flow;st

2014-03-24 14:17:20 417

原创 hdu 4183 Pahom on Water 网络流

题意   二维空间上有一些点,每个点有一个半径r和频率f,要从某一个点S走到另一个点T,然后再从T回到S。从S到T时,如果两个点表示的圆相交并且第一个点小于第二个点的频率的,那么能从第一个点到第二个点,从T到S时,第一个点的频率要大于第二个点的频率。除了S和T,每个点走后就会消失,问是否存在一种走法。相当于从源点向汇点走两次,每个点走完后消失,所以拆点,求最大流,如果最大流大于等于2或源点与汇

2014-03-20 17:32:00 492

原创 Codeforces Round #236 (Div. 2) E. Strictly Positive Matrix 强连通

题目大概意思是给定一个矩阵A,每个元素都非负,主对角线上元素大于0,问是否存在常数k,使得A的k次幂的每个元素都大于0。由A的k次幂联想到离散数学中的可达性矩阵,即问是否存在常数k,使得任意两点之间都存在长度为k的路径,因为主对角线上严格大于0,也就是说有自环,所以只要该图是强联通的即可满足,因为若任意两点之间都能走到,那么配合自环就能找到一个共同的长度k。#include#includ

2014-03-17 17:46:02 501

原创 hdu 1853 Cyclic Tour KM

#include #include #define M 310#define inf 0x3f3f3f3fint n,nx,ny;int link[M],lx[M],ly[M],slack[M]; //lx,ly为顶标,nx,ny分别为x点集y点集的个数int visx[M],visy[M],w[M][M];int DFS(int x){ visx[x] = 1;

2014-03-15 21:55:17 418

原创 hdu 3435 A new Graph Game KM

将一个无向图删边得到一些子图,并使每个子图中存在哈密顿回路,并使所有哈密顿回路上边的权值最小。因为是哈密顿图,所以每个点入度和出度必须为1,将每个点拆成u,u',对于边,连接边,,KM即可。#include #include #define M 1100#define inf 1000000int nx,ny;int link[M],lx[M],ly[M],slack[M];

2014-03-15 21:43:22 439

原创 hdu 3488 Tour KM

题目大意是有n个点,m条边,每条边有一个权值,问将所有点划分为圈的最小花费(每个点都在且仅在一个圈上)。因为每个顶点只出现一次,那么每个顶点只关联两个顶点入度顶点和出度顶点,所以构造二分图,将一个点u拆成u,u'。那么对于这个二分图如果存在着完美匹配的话,那么原图中一定存在若干个环,环中包含每个顶点,对于权值之和最小,只需求最小权匹配即可。#include #include #defi

2014-03-14 12:59:22 466

原创 hdu 3416 Marriage Match IV 最大流 最短路径

在无向图上求s到t最短路径的条数且最短路径间不能有重边(即弱独立轨)#include #include #include #include using namespace std;#define maxn 2100#define INF 100000struct node{ int u,v,dis;};struct Edge{ int from, to,

2014-03-13 11:18:12 565

原创 poj 3468 A Simple Problem with Integers 线段树

线段树的区间加减数,区间查询#include #include using namespace std;#define LL __int64const int maxn = 100100;LL sum[4*maxn];LL add[4*maxn];void build(int l,int r,int o){ add[o]=0; if(l==r) {

2014-03-11 13:35:43 513

原创 poj 1698 Alice's Chance 网络流

以电影为x节点,天数为y节点,如果电影a需在w周之前完成,那么连接该电影节点到前w周能去的那几天,容量为1,源点s点连接每个电影节点,容量为该电影需要去的天数,每一天连接汇点 t ,容量为1,表示每天只能去一个,求最大流,如果最大流等于所有应去的天数,则输出yes,否则no。#include #include #include using namespace std;#define m

2014-03-10 23:16:01 402

原创 hdu 2795 Billboard 线段树

以高为数轴,维护每个区间的剩余最大值,用线段树二分做#include #define maxn 200100int Max[4*maxn];int h,w,n;int max(int a,int b){ if(a>b) return a; else return b;}void build(int l,int r,int o){ Max[o]=w;

2014-03-09 17:06:51 461

原创 poj 2239 Selecting Courses 匹配

课程为x节点,时间为y节点,连边求最大匹配#include #include #define maxn 310int nx,ny;int g[maxn][maxn],ans,sx[maxn],sy[maxn];int cx[maxn],cy[maxn];int path(int u){ sx[u]=1; int v; for(v=1;v<=ny;v++)

2014-03-08 15:56:37 506

原创 hdu 1698 Just a Hook 线段树

线段树的区间修改#include #define maxn 100100 int set[4*maxn],sum[4*maxn];void push(int o,int m){ if(set[o]) { set[2*o]=set[2*o+1]=set[o]; sum[2*o]=(m-(m/2))*set[o]; sum[2*o+1]=(m/2)*

2014-03-08 15:53:59 472

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除