摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1839思路:先给容量从大到小排序,然后二分,每次都一次spfa一下,判断当前的cost[n]的值。。。View Code 1 #include<iostream> 2 #include<queue> 3 #include<vector> 4 typedef long long ll; 5 const int MAXN=10000+10; 6 const ll inf=1e60; 7 using namespace std; 8 struct Node{ 9 int 阅读全文
posted @ 2013-04-13 23:01 ihge2k 阅读(386) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1317思路:只要在SPFA中将一个条件,就不会进入负环。那么如果有正环呢,显然退出条件是某个点入队列次数>=n,此时退出时只需判断当前点是否与n存在路径,这步可以用Floyd来实现。。。View Code 1 #include<iostream> 2 #include<queue> 3 const int MAXN=110; 4 using namespace std; 5 int n; 6 int weight[MAXN]; 7 int power[MAXN]; 8 阅读全文
posted @ 2013-04-13 17:43 ihge2k 阅读(944) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1245思路:建图,0点为湖心,n+1点为湖外,然后bfs就可以了。。。具体见代码。View Code 1 #include<iostream> 2 #include<cmath> 3 #include<queue> 4 #define p 1e-7 5 const int inf=1<<30; 6 const int MAXN=110; 7 using namespace std; 8 double dist[MAXN][MAXN]; 9 double 阅读全文
posted @ 2013-04-13 16:20 ihge2k 阅读(224) 评论(0) 推荐(0) 编辑