摘要: A crime has been comitted: a load of grain has been taken from the barn by one of FJ's cows. FJ is trying to determine which of his C (1 <= C <= 100) 阅读全文
posted @ 2019-07-23 16:23 里昂静 阅读(260) 评论(0) 推荐(0) 编辑
摘要: 利用SPFA算法来解决hdu1874 首先了解一下SPFA的相关概念:https://baike.so.com/doc/6843451-7060772.html SPFA可以处理负权边 若给定的图存在负权边,类似Dijkstra算法等算法便没有了用武之地,SPFA算法便派上用场了。简洁起见,我们约定 阅读全文
posted @ 2019-07-23 14:23 里昂静 阅读(386) 评论(0) 推荐(0) 编辑
摘要: Dijkstra算法适用于没有负权值边的情况,用于计算一个节点到其他所有节点的最短路径。主要特点是以起始点为中心向外层层扩展,直到扩展到终点为止。 算法步骤如下: 1. 初始时令 S={V0},T={其余顶点},T中顶点对应的距离值 若存在<V0,Vi>,d(V0,Vi)为<V0,Vi>弧上的权值 阅读全文
posted @ 2019-07-23 11:14 里昂静 阅读(363) 评论(0) 推荐(0) 编辑