Wormholes-------最短路径Bellman ford

这篇博客探讨了农民John如何利用虫洞在他的农场中进行时间旅行。每个农场由多个字段、路径和虫洞组成。John希望从某个字段出发,经过一些路径和虫洞,回到起点,时间早于出发时间。博客通过输入描述农场的连接,并展示了一个Bellman-Ford算法的实现,用于检查这个目标是否可能。如果可能,输出'YES',否则输出'NO'。
摘要由CSDN通过智能技术生成

 

Wormholes

时间限制(普通/Java):3000MS/10000MS          运行内存限制:65536KByte
总提交:60            测试通过:26

描述

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 comprises N (1 ≤ N ≤ 500) fields conveniently numbered 1..N, M (1 ≤ M ≤ 2500) paths, and W (1 ≤ W ≤ 200) wormholes.

As FJ is an avid time-traveling fan, he wants to do the following: start at some field, travel through some paths and wormholes, and return to the starting field a time before his initial departure. Per

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值