HDU 1839
    
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1839题意:从1到n,要求时间小于等于T到达。每条边有一个容量,问最多能运多少货物。分析:最多能运的货物取决于路径上边的最小容量,所以二分容量,再用最短路判断时限即可。最短路里面多加一个判断保证走的边都能满足当前容...
        
阅读全文
 
            
         
        
            
    HDU 4460
    
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4460水题一道,oj时间卡的非常奇怪,把spfa的queue开成全局卡线过,别的全挂了,迪杰斯特拉的手写堆都超时,可能是卡了map?#include #include #include #include #inc...
        
阅读全文
 
            
         
        
            
    HDU 4848
    
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4848题意:求遍历所有点的最小值(这个答案是加i点到起始点的距离,不是当前点到i的距离),必须在ti[i]前到达i点题解:暴搜,剪枝是((当前值>ans)&&(当前点到未到点的时间加上起点到当前点的时间大于未到点的...
        
阅读全文
 
            
         
        
            
    HDU 4396
    
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4396题意:在至少走k条边的前提下求最短路思路:在原有最短路模板的基础上多加一维,dis[i][j]表示走到i点经过j条边的最短路,没有别的变化#include #include #include #include...
        
阅读全文
 
            
         
        
            
    HDU 4725
    
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4725求1-n最短路,每个点有一个层数,相邻层之间花费k可以到达建图时把层数看成n个点,层到该层点距离为0,点到其相邻层距离为c,相邻层之间距离为c#include #include #include #inclu...
        
阅读全文
 
            
         
        
            
    HDU 3631
    
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3631只能走标记过的点,方法是标记哪个点就对哪个点做floyd#include #include #include using namespace std ;const int INF=0xfffffff ;int...
        
阅读全文
 
            
         
        
            
    HDU 4034
    
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4034给出最短路,问最少有几条边,floyd加一个变量记录该边是否取如果满足dis[i][k]+dis[k][j]==dis[i][j],那么i到j这条边就不取如果出现dis[i][k]+dis[k][j]#inc...
        
阅读全文
 
            
         
        
            
    HDU 2807
    
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2807把矩阵相乘放在第二重循环,第三重循环只进行比较可以水过,优化的方法不懂主要用这题练习floyd的写法#include #include using namespace std ;const int INF=0...
        
阅读全文
 
            
         
        
            
    HDU 3986
    
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3986从开始的最短路里依次删一条边,求新的最短路,求最长的最短路删边操作要标记节点以及节点对应的边#include #include #include #include using namespace std ;c...
        
阅读全文
 
            
         
        
            
    HDU 1535
    
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1535水题单向图,从1到P所有点,再从所有点回到1,问最小花费先求一遍1的最短路,然后反向建图,再求一遍1的最短路#include #include using namespace std ;const int I...
        
阅读全文
 
            
         
        
            
    spfa
    
            
摘要:可判环,可算负权边,编码简单,很强的算法int spfa(int s){ for(int i=1 ;i q ; q.push(s) ; ct[s]++ ; while(!q.empty()) { int u=q.front() ; q.pop...
        
阅读全文
 
            
         
        
            
    最短路
    
            
摘要:迪杰斯特拉算法重点是松弛操作,解释为用一个dis数组记录从起点走到当前点的最短距离,如果当前点的dis值加上走到相邻点的距离小于相邻点的dis值,则更新相邻点的dis为前面两数之和。之后不断维护dis的值直到终点。实现方面可以用优先队列不断取出dis值小的点,到终点结束。head提前全置为-1,无向...
        
阅读全文
 
            
         
        
            
    HDU 2066 一个人的旅行
    
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2066裸最短路,一开始又sb了,处理错复杂度TLE,囧View Code #include #include const int INF=1000000001;const int maxn=1001;int G[m...
        
阅读全文
 
            
         
        
            
    HDU 1596 find the safest road
    
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1596最短路ps:0可以理解为那两个城市之间没有直接的通道,少看了这个条件错惨,在sx和zbw两位祖先的帮助下认清了这个问题#include #include using namespace std;const d...
        
阅读全文
 
            
         
        
            
    HDU 2112 HDU Today
    
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2112把地名和数字对应一下,就变成模板题了#include #include using namespace std;const int INF=10000000;const int maxn=101;int ni...
        
阅读全文
 
            
         
        
            
    HDU 1874 畅通工程续
    
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1874第一次知道有个东西叫重边。。。囧View Code #include #include using namespace std;const int INF=1000000000;int map[210][21...
        
阅读全文
 
            
         
        
            
    HDU 2544 最短路
    
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2544在TCO又一次0之后。。。突然会写最短路了,ORZView Code #include #include using namespace std;const int INF=100000000;int map...
        
阅读全文