Submission #559036

#TimeUsernameProblemLanguageResultExecution timeMemory
559036jh05013Price List (POI13_cen)Pypy 3
0 / 100
442 ms65536 KiB
from heapq import * import sys;input=lambda:sys.stdin.readline().strip('\n') MIS = lambda: map(int,input().split()) n, m, source, c1, c2 = MIS() adj = [set() for i in range(n+1)] for i in range(m): a, b = MIS() adj[a].add(b); adj[b].add(a) dist = [10**18]*(n+1); dist[source] = 0 PQ = [(0, source)] while PQ: d, u = heappop(PQ) if dist[u] != d: continue for v in adj[u]: # edge type 1 nd = d+c1 if dist[v] <= nd: continue dist[v] = nd; heappush(PQ, (nd, v)) # edge type 2 nd = d+c2 to_remove = [] for v2 in adj[v]: if v2 in adj[u] or dist[v2] <= nd: continue dist[v2] = nd; heappush(PQ, (nd, v2)) to_remove.append(v2) for v2 in to_remove: adj[v].remove(v2) print(*dist[1:])
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...