https://atcoder.jp/contests/past202005-open/tasks/past202005_m

scipy.sparse.csgraph

python

graph = lil_matrix((N + 1, N + 1))
for i in range(M):
    v1, v2 = map(int, input().split())
    graph[v1, v2] = 1
    graph[v2, v1] = 1

start = int(input())
K = int(input())
targets = list(map(int, input().split()))

dist = dijkstra(graph, indices=targets)
print(dist)

This page is auto-translated from /nishio/PAST202005M using DeepL. If you looks something interesting but the auto-translated English is not good enough to understand it, feel free to let me know at @nishio_en. I’m very happy to spread my thought to non-Japanese readers.