
最短路
dregs_
小菜鸟
展开
-
C - Constructing Roads
There are N villages, which are numbered from 1 to N, and you should build some roads such that every two villages can connect to each other. We say two village A and B are connected, if and only if there is a road between A and B, or there exists a villag原创 2020-08-08 16:41:19 · 178 阅读 · 0 评论 -
H - 畅通工程再续
相信大家都听说一个“百岛湖”的地方吧,百岛湖的居民生活在不同的小岛中,当他们想去其他的小岛时都要通过划小船来实现。现在政府决定大力发展百岛湖,发展首先要解决的问题当然是交通问题,政府决定实现百岛湖的全畅通!经过考察小组RPRush对百岛湖的情况充分了解后,决定在符合条件的小岛间建上桥,所谓符合条件,就是2个小岛之间的距离不能小于10米,也不能大于1000米。当然,为了节省资金,只要求实现任意2个小岛之间有路通即可。其中桥的价格为 100元/米。Input输入包括多组数据。输入首先包括一个整数T(T &l原创 2020-08-08 14:06:14 · 148 阅读 · 0 评论 -
spfa算法最短路
介绍SPFA(Shortest Path Faster Algorithm) 算法是 Bellman-Ford算法 的队列优化算法的别称,通常用于求含负权边的单源最短路径,以及判负权环。SPFA 最坏情况下复杂度和朴素 Bellman-Ford 相同,为 O(VE)。为了避免最坏情况的出现,在正权图上应使用效率更高的Dijkstra算法。算法特点1.时间复杂度比Dijkstra和ford低。2.能够计算负权图的问题。3.能够判断是否有负环。4.与bfs算法比较,复杂度相对稳定,但在稠密图中复杂原创 2020-08-02 23:20:06 · 440 阅读 · 0 评论 -
Wormholes
While exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is very peculiar because it is a one-way path that delivers you to its destination at a time that is BEFORE you entered the wormhole! Each of FJ’s farms co原创 2020-08-02 23:18:28 · 196 阅读 · 0 评论 -
Frogger
Description\color{blue}{Description}DescriptionFreddy 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,原创 2020-07-30 23:12:49 · 166 阅读 · 0 评论 -
D - 六度分离
Description\color{blue}{Description}Description1967年,美国著名的社会学家斯坦利·米尔格兰姆提出了一个名为“小世界现象(small world phenomenon)”的著名假说,大意是说,任何2个素不相识的人中间最多只隔着6个人,即只用6个人就可以将他们联系在一起,因此他的理论也被称为“六度分离”理论(six degrees of separation)。虽然米尔格兰姆的理论屡屡应验,一直也有很多社会学家对其兴趣浓厚,但是在30多年的时间里,它从来就没有原创 2020-07-29 18:42:56 · 176 阅读 · 0 评论 -
C - Til the Cows Come Home
Description\color{blue}{Description}DescriptionBessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Bessie needs her beauty sleep, so she wants to get back as q原创 2020-07-29 18:19:27 · 193 阅读 · 0 评论 -
B - HDU Today
Description\color{blue}{Description}Description经过锦囊相助,海东集团终于度过了危机,从此,HDU的发展就一直顺风顺水,到了2050年,集团已经相当规模了,据说进入了钱江肉丝经济开发区500强。这时候,XHD夫妇也退居了二线,并在风景秀美的诸暨市浬浦镇陶姚村买了个房子,开始安度晚年了。这样住了一段时间,徐总对当地的交通还是不太了解。有时很郁闷,想去一个地方又不知道应该乘什么公交车,在什么地方转车,在什么地方下车(其实徐总自己有车,却一定要与民同乐,这就是徐总原创 2020-07-27 21:17:50 · 153 阅读 · 0 评论