Messengers
- DevBobcorn
- 2019年5月26日
- 読了時間: 1分
With Floyd Algorithm and Dijkstra Algorithm, we 're working out another interesting problem, the problem of Messengers. Here's the description:
On the battle field, Leonard Vanderboom wants to send out a message to his comrades, but he could only use his pigeons, each of his comrades has his pigeons, too.

And the map's like this:

Now, the question is, how soon will all his comrades know the message?
Here's the code (Floyd):
And a simple Dijkstra version:
The following input solves the problem of Leonard Vanderboom:
4 4
1 2 4
2 3 7
2 4 1
3 4 6
The program might be also useful in many other situations with only a little modifications, enjoy!☺
Comentários