We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
If you want a better framework to start from so you can just start coding, here is a better starting point for Python 3 in the usual Hackerrank style:
#!/bin/python3importmathimportosimportrandomimportreimportsys## Complete the 'floyd' function below.## The function is expected to return an INTEGER_ARRAY.# The function accepts following parameters:# 1. INTEGER n the number of nodes# 2. INTEGER m the number of edges# 3. INT ARRAY starts, the starting point of an edge # 4. INT ARRAY ends, the ending point of an edge# 5. INT ARRAY costs, the cost of an edge # 6. LIST of TUPLES queries, where each tuple is (start, end)#deffloyd(n,m,starts,ends,costs,queries):#Write your code hereif__name__=='__main__':road_nodes,road_edges=map(int,input().rstrip().split())road_from=[0]*road_edgesroad_to=[0]*road_edgesroad_weight=[0]*road_edgesforiinrange(road_edges):road_from[i],road_to[i],road_weight[i]=map(int,input().rstrip().split())q=int(input().strip())queries=[]forq_itrinrange(q):first_multiple_input=input().rstrip().split()x=int(first_multiple_input[0])y=int(first_multiple_input[1])queries.append([x,y])answers=floyd(road_nodes,road_edges,road_from,road_to,road_weight,queries)foransinanswers:print(ans)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Floyd : City of Blinding Lights
You are viewing a single comment's thread. Return to all comments →
If you want a better framework to start from so you can just start coding, here is a better starting point for Python 3 in the usual Hackerrank style: