You are viewing a single comment's thread. Return to all comments →
Did not work for me :( Does it work for you? I feel the performance issue arises when converting the input to an int.
int
The following parsing works for me (bottlenecks are: int conversion and selecting the min edge weight):
numqueries = int(input()) for _ in range(numqueries): n, m = tuple(map(int, input().split())) edges = dict() for _ in range(m): u, v, r = readedge(sys.stdin.readline()) key = (u, v) if key in edges: edges[key] = min(r, edges[key]) else: edges[key] = r edges = [(u,v,r) for (u,v),r in edges.items()] startnode = int(input()) assert len(edges) <= m, (len(edges), m) print(" ".join(dijkstra(n, edges, startnode)))
Seems like cookies are disabled on this browser, please enable them to open this website
Dijkstra: Shortest Reach 2
You are viewing a single comment's thread. Return to all comments →
Did not work for me :( Does it work for you? I feel the performance issue arises when converting the input to an
int
.The following parsing works for me (bottlenecks are:
int
conversion and selecting the min edge weight):