結果

問題 No.994 ばらばらコイン
ユーザー RK PythonRK Python
提出日時 2020-06-25 13:14:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 534 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 10,852 KB
実行使用メモリ 48,060 KB
最終ジャッジ日時 2023-09-16 22:37:19
合計ジャッジ時間 4,971 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 15 ms
7,820 KB
testcase_02 AC 15 ms
8,244 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 14 ms
8,248 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 15 ms
7,888 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 14 ms
8,252 KB
testcase_17 AC 15 ms
7,844 KB
testcase_18 AC 14 ms
8,176 KB
testcase_19 WA -
testcase_20 AC 15 ms
8,116 KB
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K = [int(i) for i in input().split()]
if N < K:
    print(-1)
    exit()
graph = {i:set() for i in range(1,N+1)}
for _ in range(N-1):
    a,b = [int(i) for i in input().split()]
    graph[a].add(b)
    graph[b].add(a)

que = [1]
seen = {1}
move = 0
while que:
    node = que.pop()
    for n in graph[node]:
        if n not in seen:
            seen.add(n)
            que.append(n)
            K -= 1
            if K != 0:
                move += 1
                break
    seen.add(node)
    if K == 0:
        break
print(move)
0