雕刻时光

just do it……nothing impossible
随笔 - 547, 文章 - 0, 评论 - 82, 阅读 - 86万
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

随笔分类 -  网络流

摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3549View Code #include<stdio.h>#include<iostream>#include<algorithm>using namespace std;typedef struct {int v,next,val;} edge;const int MAXN=20010;const int MAXM=500010; edge e[MAXM];int p[MAXN],eid; inline void init(){memset(p,-1,sizeof(p) 阅读全文

posted @ 2012-04-10 18:27 huhuuu 阅读(582) 评论(0) 推荐(0) 编辑

摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3739建图用LIS处理数字10 10 20 1 2 2 ->>dp :1 1 2 1 1 2 MAX=2每个点拆做两个点建图 s 连所有dp为1的点前驱(i)汇点t连所有dp为max的点后驱(i+n)点与点的关系如果点 i与点j(i<j) dp[i]+1== [j]&&s[i]<s[j]则点i前驱与点j后驱建立容量为1的容量网络最小割OKView Code #include<iostream>#include<cmath>#include< 阅读全文

posted @ 2012-04-05 20:18 huhuuu 阅读(284) 评论(0) 推荐(0) 编辑

摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1788注意门与门之间可能有多条路!!输入可以连通就相应的边就 + INF判断 map[i][j]>=inf 反面就又map[j][i]=map[i][j]/inf 容量的路算最大流,if flow>=inf 则 入侵 else flowView Code #include<stdio.h>#include<string.h>int map[39][39];const int inf=100000000;const int MAXN=39;i 阅读全文

posted @ 2012-03-29 22:24 huhuuu 阅读(382) 评论(0) 推荐(0) 编辑

摘要:类似于二分匹配的构图,相乘可以用log 后相加解决View Code #include<iostream>#include<cmath>#include<stdio.h>#include<string.h>using namespace std;const double inf=500.0;const int MAX=105;struct node{ int v,next; double c;}g[100000];int num[MAX],dis[MAX],cur[MAX],adj[MAX],pre[MAX];int s,t,e,vn,r,c,l 阅读全文

posted @ 2012-03-28 21:45 huhuuu 阅读(272) 评论(0) 推荐(0) 编辑

摘要:http://poj.org/problem?id=3469网络流的模型:每个模块一个节点,原点与所有模块节点连接(称为上边),边权为第一个核对应该模块的开销。所有模块节点连接到汇点(称为下边),权为第二个核对应该模块的开销。然后需要数据交换的两个模块结点之间连接双向边(两个单向边,称为中边),权为对应的那个额外开销。View Code #include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int MAXN = 20000;const int INF = 1 阅读全文

posted @ 2012-03-24 22:03 huhuuu 阅读(278) 评论(0) 推荐(0) 编辑

摘要:http://poj.org/problem?id=1637题意:混合图欧拉回路一开始想到是否可以用欧拉回路做,可是一想a->b ,a<->b可以同时并且多次存在时,不可行构图:有向边忽略,无向边任意定向。统计每个点的出入度(有向边当无向边)。对于任意一个点,若有出入度之差为奇数则不可能存在欧拉路。记|出度-入度|=K。对于出度大于入度的点从S向I连容量为K/2的边,对于出度小于入度的点从I向T连容量为K/2的边。原来的无向边,任意定向,从X向Y连容量1的边。求最大流,判每条从S流出的边的流量和all是否等于最大流,是则存在欧拉路否则不存在。注意点:会有重边出现!而且重边也要 阅读全文

posted @ 2012-03-22 21:51 huhuuu 阅读(676) 评论(0) 推荐(0) 编辑

摘要:先 folyd 求出任意两点可以到达的距离,由于我们不知道最短距离为多少,所以用二分查找来逼近答案接着构建容量网络:增加 源点 (n+1),设置源点到牛的容量为1 (一开始以为是INF,显然是错的)增加 汇点 (0),设置汇点到机器的容量为 M在通过二分出来的那个答案,统计牛到机器的容量最后网络流最大流,继续二分,直到最佳答案View Code #include<stdio.h>#include<string.h>const int inf=100000000;const int MAXN=309;int map[MAXN][MAXN];int dis[MAXN][MA 阅读全文

posted @ 2012-03-21 22:36 huhuuu 阅读(337) 评论(0) 推荐(0) 编辑

摘要:http://poj.org/problem?id=1273人生第一题网络流O(∩_∩)O哈哈~注意数据有重边,要把值加上去View Code #include<stdio.h>const int inf=1000000000;const int MAXN=209;int map[MAXN][MAXN];int flow[MAXN][MAXN];int max_flow(int n,int mat[][MAXN],int source,int sink){ int v[MAXN],c[MAXN],p[MAXN],ret=0,i,j; for(;;){ for(i=0;... 阅读全文

posted @ 2012-03-21 19:47 huhuuu 阅读(376) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示