結果

問題 No.812 Change of Class
ユーザー maspy
提出日時 2020-02-07 10:44:50
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 559 bytes
コンパイル時間 257 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 89,516 KB
最終ジャッジ日時 2024-06-12 21:59:17
合計ジャッジ時間 70,941 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 60
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np
from scipy.sparse.csgraph import connected_components, dijkstra
from scipy.sparse import csr_matrix

data = np.fromstring(read(), np.int64, sep=' ')

N, M = data[:2]
UV = data[2:2+M+M]
U = UV[::2]
V = UV[1::2]
Q = data[2+M+M]
A = data[2+M+M+1:]

graph = csr_matrix((np.ones_like(U), (U, V)), (N+1, N+1))

_, comp = connected_components(graph)
comp_size = np.bincount(comp)

dist = dijkstra(graph, directed=False, indices=A)
0