Блог пользователя StandAlone1234

Автор StandAlone1234, история, 4 года назад, По-английски

Can anybody help me with the problem? Floyd Warshall

Why one approach is wrong and one approach correct? Explanation with examples will be highly appreciated.

Code

Thanks

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
4 года назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

I have no idea how to interpret dp when you put k in the inner loop. In Floyd-Warshall, k represents the intermediate vertex, i.e., the algorithm updates dp when it finds a shorter path passing through k.

»
4 года назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

You can get correct answer if you run the incorrect FW 3 times. https://codeforces.me/blog/entry/89442 (Comments)