上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 19 下一页
摘要: 英语不好,懒得看题意,在网上搜的题意题目连接:http://poj.org/problem?id=1273题目大意:每当下雨,农夫FJ最喜爱的养尊处优的地方周围就变成了一个池塘,这让他很不爽,所以决心要把这个问题解决掉,所以他就在四周建造了一些渠沟以便排水,更为巧妙地是可以把这水排到一个小溪处。编号为1的节点作为池塘,编号为n的地方作为小溪。求最大排水量注意重边的情况就可以了;若菜一开始 打的代码没初始化,结果WA最大流基础入门:http://www.cnblogs.com/0803yijia/archive/2013/01/18/2865837.html代码:View Code #inclu 阅读全文
posted @ 2013-01-18 10:37 某某。 阅读(466) 评论(0) 推荐(0) 编辑
摘要: 原文地址:http://blog.sina.com.cn/s/blog_6cf509db0100uy5n.html因为是初学教程,所以我会尽量避免繁杂的数学公式和证明。也尽量给出了较为完整的代码。本文的目标群体是网络流的初学者,尤其是看了各种NB的教程也没看懂怎么求最大流的小盆友们。本文的目的是,解释基本的网络流模型,最基础的最大流求法,即bfs找增广路法,也就是EK法,全名是Edmond-Karp,其实我倒是觉得记一下算法的全名和来历可以不时的拿出来装一装。比如说这个,EK算法首先由俄罗斯科学家Dinic在1970年提出,没错,就是dinic算法的创始人,实际上他提出的也正是dinic算法, 阅读全文
posted @ 2013-01-18 08:43 某某。 阅读(491) 评论(0) 推荐(0) 编辑
摘要: 题目连接:http://poj.org/problem?id=3026这题数据太坑了。。。不看解题报告不知道。。。尼玛,m,n后面不能加getchar(),得加gets(s);尼玛是有多少个空格啊~wa了N遍啊思路 先求点,然后对每一个点进行一次bfs,然后存距离,之后直接最小生成树。一开始我是用两个for循环去的值,直接超时。。。代码:View Code 1 #include <iostream> 2 #include <stdio.h> 3 #include <string.h> 4 5 using namespace std; 6 struct nod 阅读全文
posted @ 2012-11-15 00:32 某某。 阅读(207) 评论(0) 推荐(0) 编辑
摘要: 题目连接:http://poj.org/problem?id=2485题意比较明显。。。就是求最小生成树里的最长路,其实用dijks也可以。。。View Code 1 #include <iostream> 2 #include <stdio.h> 3 #define max 65536; 4 using namespace std; 5 6 int map[505][505]; 7 int ans; 8 void init(int n) 9 {10 int i,j;11 for(i = 1;i <= n;i++)12 {13 for(j = 1;j... 阅读全文
posted @ 2012-11-13 20:15 某某。 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 题目连接:http://poj.org/problem?id=1789每条边的权值为任意两truck不相等字母的数量,求最小生成树代码:View Code 1 #include <iostream> 2 #include <stdio.h> 3 #include <string.h> 4 #define max 1000000 5 using namespace std; 6 int map[2005][2005]; 7 int ans; 8 void prim(int n) 9 {10 int i,pre,j,min;11 int vis[2005] = 阅读全文
posted @ 2012-11-13 18:23 某某。 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 题目连接:http://poj.org/problem?id=2240思路:直接见图,floyd一遍之后看是否有自身大于一的。注意是有向图代码:View Code 1 #include <iostream> 2 #include <map> 3 #include <string> 4 #include <stdio.h> 5 using namespace std; 6 map<string,int> st; 7 string s1,s2; 8 double mp[50][50]; 9 void init(int n)10 {11 i 阅读全文
posted @ 2012-11-13 17:43 某某。 阅读(122) 评论(0) 推荐(0) 编辑
摘要: 题目连接:http://poj.org/problem?id=1125题目就是要求你算每个点在能够到达所有点的情况下求到达所有点的费时中最大的最小值及其起点,如果不能到达直接输出disjoint。代码View Code 1 #include <iostream> 2 #include <stdio.h> 3 #define max 1000000 4 using namespace std; 5 int map[106][105]; 6 void init(int n) 7 { 8 int i,j; 9 for(i = 1;i <= n;i++)10 {11 .. 阅读全文
posted @ 2012-11-13 16:59 某某。 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 有N个点,青蛙A 在点1上,青蛙B在点2上,然后青蛙可以通过剩下的点来到达2点,求各个通路中最大的一段中的最小值~题目连接http://poj.org/problem?id=2253我的代码:View Code 1 #include <stdio.h> 2 #include <string.h> 3 #include <math.h> 4 #include<algorithm> 5 #include <iostream> 6 using namespace std; 7 8 int n; 9 10 struct node11 {12 阅读全文
posted @ 2012-11-10 21:03 某某。 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=4462当时比赛的时候读错题意了。。。很悲催的没有考虑n*n个稻草人的时候。。。。然后一直WA= =。。。悲剧啊。。。。回来的时候崔老师教了一个枚举的办法。。。就是位运算。。之前做的一道DFS也可以用位运算来写(其实取1或者取0的dfs都可以用位运算写= =)~、膜拜崔老师~View Code #include <iostream>#include <math.h>#include <stdio.h>#include <string.h>#include 阅读全文
posted @ 2012-11-10 14:19 某某。 阅读(276) 评论(0) 推荐(0) 编辑
摘要: 题意不再赘述。。。连接http://acm.hdu.edu.cn/showproblem.php?pid=4460此题直接郁闷致死。。。。比赛的时候用的是floyd然后直接超时。。。当时闪过spfa的想法,但是觉得如果是一个循环spfa话也会超时。。。今天试了一下。。。果然超时= =。。。郁闷啊亲。。。然后优化了一下,用一个邻接表去存边。一开始忽略了一点就是-1的输出。。。代码。View Code 1 #include <stdio.h> 2 #include <iostream> 3 #define inf 10000 4 #include <map> 5 阅读全文
posted @ 2012-11-08 23:27 某某。 阅读(453) 评论(6) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 19 下一页