結果

問題 No.330 Eigenvalue Decomposition
ユーザー 山本信二
提出日時 2022-04-05 16:59:52
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
MLE  
実行時間 -
コード長 447 bytes
コンパイル時間 468 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 1,654,052 KB
最終ジャッジ日時 2024-11-26 20:28:47
合計ジャッジ時間 85,937 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 17 TLE * 2 MLE * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix
n, m = map(int, input().split())
graph = [[0]*n for _ in range(n)]
for _ in range(m):
    a, b,c = map(int, input().split())
    graph[a-1][b-1] = 1
    graph[b-1][a-1] = 1  # 有向グラフなら消す# [[0, 1, 1, 0, 1], ..., [1, 0, 1, 1, 0]]

a = np.array(graph)

# <class 'numpy.ndarray'>

n, labels = connected_components(a)
print(n)
0