結果

問題 No.994 ばらばらコイン
ユーザー Soratop
提出日時 2020-12-18 00:57:49
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 281 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 888,396 KB
最終ジャッジ日時 2024-09-21 08:46:06
合計ジャッジ時間 7,697 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 2 MLE * 1 -- * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
import scipy.sparse.csgraph
n,k=map(int,input().split())
a=np.array([[0]*n for i in range(n)])
for i in range(n-1):
    b,c=map(int,input().split())
    a[b-1][c-1]=1
d=k-sum(i==1 for i in scipy.sparse.csgraph.shortest_path(a,indices=0))
print(-1 if d>=2 else d)
0