Floyd : City of Blinding Lights

  • + 0 comments

    Main difference of TLE and pass of case 5 and 6 are just the use of min for python 3, any early termination won't save you if min is used

    TLE

    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
    or
    if dist[i][k] != float('inf') and dist[k][j] != float('inf'):
                        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
    

    Pass

                    if dist[i][j] > dist[i][k] + dist[k][j]: 
                        dist[i][j] = dist[i][k] + dist[k][j]