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

Автор ThomazL, история, 9 лет назад, По-английски

Hi everyone, recently tried to solve this problem. In the forum, a guy says to settle with Floyd-Warshall, but I do not know how to do that '-'

Can anyone explain me how to solve this problem used Floyd-Warshall algorithm?

Problem in a nutshell: You have a graph (N <= 100) and M querys. Each query asks about the minimum distance between two vertices using a maximum K steps.

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

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

You can use a modification of Matrix Exponentiation similar to Floyd-Warshall, see : This book for a tutorial (page 220).

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

I think you didn't understand the problem correctly, It says "t indicates that cities 1,2, .., t can be used for stopovers."

So t doesn't indicate the number of cities that you can visit, it indicates that you can only use cities from 1 => t, and this is a straight forward Floyd Problem.