![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Floyd
Jerry99s
OI -> ACM -> AI
展开
-
Floyd判圈算法:UVA-11549 Calculator Conundrum
题目: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=27&page=show_problem&problem=2544 分析:Floyd判圈算法 代码: #include <cstdio> #include <algorithm&...原创 2015-06-13 21:48:03 · 304 阅读 · 0 评论 -
Floyd邻接表优化:Poj3275 Ranking the Cows
题目: http://poj.org/problem?id=3275 分析: 如果要对n个数排序,需要知道任意两个数的大小关系,即n*(n-1)/2对关系; 现在知道m条边(a>b),由此可以确定知道了多少对大小关系(假设为sum对); 则答案为n*(n-1)/2 - sum; 如何知道任意两对是否已经知道了大小关系? 很容易想到Floyd,可是O(n^3)会超时,这里用邻接表...原创 2018-02-28 10:50:33 · 264 阅读 · 0 评论