Skip to main content
  1. Tags/

Floyd

2016

hdu 2448 Mining Station on the Sea (floyd+KM)

·997 words·2 mins
hdu2448 题目链接 题意:n 艘船 n 个港口,一个港口只能承接一艘船,m 个油田,给出 n 艘船各自在哪个油田,然后给出 m 个油田之间的无向图,然后给出油田和港口之间的有向图。求 n 艘船到达港口的最小距离之和。

bc #74 div1 1001 || hdu 5636 Shortest Path (floyd?)

·574 words·2 mins
题目链接 题意:有一条n个节点的链,节点i和节点j的距离为abs(i-j) 现在新增加三条边,距离也都为1,然后给出m个询问,每组询问给出两个点s,t,问s,t之间的最短距离。 思路:比赛的时候没搞出来。 观察特点,对于大多数点来说,都是没有直接的改变,只是增加了三条边。总的思路是:之前s到t的距离为abs(s-t),通过枚举中间经过的特殊点,观察是否能使得距离减小。

2015

poj 3660 Cow Contest (floyd,传递闭包)

·492 words·1 min
http://poj.org/problem?id=3660 题意:给定n个奶牛,m个奶牛的关系,a,b表示a比b强…问能确定多少个奶牛的排名。 思路:最重要的一点是。。能确定奶牛i的排名的条件是。。知道奶牛i和其他n-1个奶牛的关系。。不管是能打败奶牛i也好。。会被奶牛i打败也好。。只要不是不确定就行。。所以我们跑一遍floyd做传递闭包。得到任何两个点之间的联系。然后对于每一个点。看其他n-1个点是否和他有关系。

codeforces 500 B. New Year Permutation

·499 words·1 min
http://codeforces.com/contest/500/problem/B 题意:给定一个1至n的数的一种排列。给定一个n*n的矩阵,a[i][j]==0代表pi,pj不可以交换,a[i][j]为1代表p[i],p[j]可以交换。 问字典序最小的排列。。

POJ 2253 - Frogger (floyd)

·622 words·2 mins
A - Frogger **Time Limit:**1000MS **Memory Limit:**65536KB 64bit IO Format:%I64d & %I64u Submit Status Description Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sitting on another stone. He plans to visit her, but since the water is dirty and full of tourists’ sunscreen, he wants to avoid swimming and instead reach her by jumping. Unfortunately Fiona’s stone is out of his jump range. Therefore Freddy considers to use other stones as intermediate stops and reach her by a sequence of several small jumps. To execute a given sequence of jumps, a frog’s jump range obviously must be at least as long as the longest jump occuring in the sequence. The frog distance (humans also call it minimax distance) between two stones therefore is defined as the minimum necessary jump range over all possible paths between the two stones.