ThomazL's blog

By ThomazL, history, 7 years ago, In English

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.

  • Vote: I like it
  • +10
  • Vote: I do not like it

| Write comment?
»
7 years ago, # |
Rev. 4   Vote: I like it +3 Vote: I do not like it

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

»
7 years ago, # |
Rev. 2   Vote: I like it +9 Vote: I do not like it

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.

  • »
    »
    7 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    omg, you are correct '-'. I have to return to primary for learn read xD

    Thanks for advice

    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Where can I test my solution to that problem??

      • »
        »
        »
        »
        6 years ago, # ^ |
          Vote: I like it +8 Vote: I do not like it

        Had you noticed that on the top of the page, written URI Online Judge | 2130 ? That means it is 2130 number problem of URI OJ. So you just need to google: URI Online Judge 2130

        By the way, link to the problem is: Here