12 2013 档案

图论专题III
摘要:[vijos美食节]最小费用流From:https://www.vijos.org/p/1726Solution:假设厨师i做菜品j做n次, 那么第k次做时对答案的贡献就是(n-k+1)*t[j][i]。我们把每个厨师进行拆点, 建图用费用流即可算出答案。但是这题图较大, 需要动态加边。#include #include #include #include #include #include #include #include #include using namespace std;#define N 45#define M 101#define oo 0x6fffffff#define n 阅读全文

posted @ 2013-12-28 15:38 leezyli 阅读(261) 评论(0) 推荐(0)

图论专题II
摘要:[vijos 生命之泉]最大费用流From:https://www.vijos.org/p/1525Solution:和炸毁燃料库一样,参见http://www.cnblogs.com/leezy/p/3472910.html#include #include #include #include #include #include #include #include using namespace std;#define N 1005#define M 705#define oo 0x6fffffff#define nil (-1)struct {int w,c,to,next;} nod[N 阅读全文

posted @ 2013-12-15 16:00 leezyli 阅读(248) 评论(0) 推荐(0)

图论专题I
摘要:[pku2396 Budget]带源汇的上下界最大流From:http://poj.org/problem?id=2396#include #include #include #include #include #include #include #include using namespace std;#define N 205+25#define M 25#define oo 0x6fffffff#define nil (-1)int cap[N][N], flow[N][N], d[N], fa[N], low[N][N], high[N][N], in[N], out[N], maxf 阅读全文

posted @ 2013-12-13 13:35 leezyli 阅读(268) 评论(0) 推荐(0)

[ZJOI2006 物流运输trans] 最短路径 DP SPFA
摘要:From:http://www.lydsy.com/JudgeOnline/problem.php?id=1003Solution:记cost[i,j]表示i到j天不换路径的最小成本, dp[i]表示前i天的最小成本, 得dp[i] = min(dp[i], dp[j]+cost[j+1,i]+K),其中0<=j<i./************************************************************** Problem: 1003 User: leezy Language: C++ Result: Accepted Time... 阅读全文

posted @ 2013-12-08 21:11 leezyli 阅读(159) 评论(0) 推荐(0)

[HAOI2006 受欢迎的牛] 强联通分量 缩点
摘要:From:http://www.lydsy.com/JudgeOnline/problem.php?id=1051Solution:1.根据题目描述建立图G, 对于任意(a,b)属于G, 表示a认为b受欢迎2.显然, 对于任意的强联通分量C, 对任意(a,b)属于C, a,b都是C中受欢迎的3.缩点,建立SCC图,在原图G中的任意边(a,b), 反向后得到SCC图,显然SCC图是一个有向无回路图。现在,解规约为一个判定性问题: SCC图中是否存在一个点u, u可达SCC图中的所有顶点?4.判断是否存在这样的顶点/***************************************** 阅读全文

posted @ 2013-12-07 23:33 leezyli 阅读(150) 评论(0) 推荐(0)

[BeiJing2006 狼抓兔子] 最大流
摘要:From:http://www.lydsy.com/JudgeOnline/problem.php?id=1001Solution:这题用sap水过了, 更快的做法是转化成平面图来搞?/************************************************************** Problem: 1001 User: leezy Language: C++ Result: Accepted Time:1292 ms Memory:141744 kb****************************************... 阅读全文

posted @ 2013-12-07 21:25 leezyli 阅读(175) 评论(0) 推荐(0)

[最大数MaxNumber] 树状数组
摘要:From:http://www.lydsy.com/JudgeOnline/problem.php?id=1012Solution:用树状数组维护最大值/************************************************************** Problem: 1012 User: leezy Language: C++ Result: Accepted Time:500 ms Memory:1588 kb***********************************************************... 阅读全文

posted @ 2013-12-07 14:31 leezyli 阅读(290) 评论(0) 推荐(0)

导航