摘要: #include #include #define N 200200int max[4*N];int n,m;int A,B;int L,R;int MAX(int a,int b){ if(a>b) return a; else return b;}int MIN(int a,int b){ if... 阅读全文
posted @ 2013-12-23 00:24 贝尔摩德 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 将人拆点,之间连接一条容量为1的边,表示一个人只能选一次,从s到每种食物连接一条容量为该种食物总数的边,从每种饮料连接一条容量为该种饮料总量的边,如果一个人喜欢某种食物或饮料,连边即可。#include #include #include using namespace std;const int ... 阅读全文
posted @ 2013-12-22 21:23 贝尔摩德 阅读(95) 评论(0) 推荐(0) 编辑
摘要: AC自动机的裸题,不过需要注意几个地方,keywords中有重复的,而且模板中会重复出现keywords~#include #include #define SIGMA_SIZE 26#define MAXNODE 500100using namespace std;int ch[MAXNODE][... 阅读全文
posted @ 2013-12-21 11:50 贝尔摩德 阅读(169) 评论(0) 推荐(0) 编辑
摘要: 注意一个地方,在建立好层次图进行dfs增广时,如果某个点增广不出流量,那么将该点level值置为0,即将它在该层次图中删除,剪枝,否则会超时~#include #include #include using namespace std;const int maxn=1050;#define inf ... 阅读全文
posted @ 2013-12-20 16:18 贝尔摩德 阅读(155) 评论(0) 推荐(0) 编辑
摘要: #include #include #define Max 300#define INF 5000000int flow[Max][Max],d[Max];int map[Max][Max];int sta,end; int m,n;int min(int a,int b){ if(a0&&d... 阅读全文
posted @ 2013-12-17 20:38 贝尔摩德 阅读(132) 评论(0) 推荐(0) 编辑
摘要: #include #include #define maxn 110int nx,ny;int map[maxn][maxn],ans,sx[maxn],sy[maxn];int cx[maxn],cy[maxn];int down;int l,r,mid;int path(int u){ s... 阅读全文
posted @ 2013-12-15 13:16 贝尔摩德 阅读(118) 评论(0) 推荐(0) 编辑
摘要: #include #include #include using namespace std;#define Max 230#define INF 100000000int flow[Max][Max],d[Max];int vis[Max*3];int sta,end; vector sum;i... 阅读全文
posted @ 2013-12-12 17:12 贝尔摩德 阅读(125) 评论(0) 推荐(0) 编辑
摘要: #include #include #include using namespace std;const int maxn=20000+50,inf=100000000;int n,m;int level[maxn],que[maxn*10];int head[maxn*3],lon;int min... 阅读全文
posted @ 2013-12-12 17:00 贝尔摩德 阅读(99) 评论(0) 推荐(0) 编辑
摘要: #include #include #define maxn 10050int n,m;int p[maxn],x[maxn*10],y[maxn*10];int find(int x){ if(p[x]==x) return x; else return p[x]=find(p[x]);}int ... 阅读全文
posted @ 2013-12-10 23:25 贝尔摩德 阅读(91) 评论(0) 推荐(0) 编辑
摘要: Kosaraju算法是求解有向图强连通分量(strongconnectedcomponent)的三个著名算法之一,能在线性时间求解出一个图的强分量。用Sedgewick爷爷的话说,就是“现代算法设计的胜利”。什么是强连通分量?在这之前先定义一个强连通性(strongconnectivity)的概念:... 阅读全文
posted @ 2013-12-09 11:27 贝尔摩德 阅读(232) 评论(0) 推荐(0) 编辑