O(1) 的小乐
豆瓣账号:http://www.douban.com/people/sosisarah/
摘要: 货币兑换问题,经典问题,这个问题解决的关键是发现,如果存在正环,那么一定是YES。稍微改一下SPFA,寻找一个图中的正环。 1: /** 2: search the longest path , just jude whether there are a positve cycle. 3: 4: */ 5: 6: #include <queue> 7... 阅读全文
posted @ 2012-11-09 23:26 O(1)的小乐 阅读(1861) 评论(0) 推荐(0) 编辑
摘要: 一道简单的差分约束方程,差分约束方程由Bellmanford转换而来,一组差分方程由 x-y <=d 的形式,而在最短路中松弛条件有dis(x)<= dis(y)+w。 所以产生了一条由y连向x的有向边,权重为d。 https://github.com/Sosi/ProgrammingContest/blob/master/OnlineJudge/POJ/PKU3169.cpp 1: ... 阅读全文
posted @ 2012-11-09 21:39 O(1)的小乐 阅读(219) 评论(0) 推荐(0) 编辑
摘要: 给定一个图,(V 3*10^4, E 1.5*10^5),如此大规模的图,求一个最短路,只能使用SPFA(使用栈进行优化) https://github.com/Sosi/ProgrammingContest/blob/master/OnlineJudge/POJ/PKU3159.cpp 1: #include <queue> 2: #include <iostream> 3: ... 阅读全文
posted @ 2012-11-09 21:17 O(1)的小乐 阅读(236) 评论(0) 推荐(0) 编辑