結果

問題 No.1582 Vertexes vs Edges
ユーザー H3PO4
提出日時 2023-03-01 08:55:50
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 425 bytes
コンパイル時間 110 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 28,416 KB
最終ジャッジ日時 2024-09-16 08:51:23
合計ジャッジ時間 8,938 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 3 WA * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.buffer.readline

N = int(input())
T = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v = tuple(int(x) - 1 for x in input().split())
    T[u].append(v)
    T[v].append(u)

b = [None] * N
b[0] = True
stk = [0]
while stk:
    v = stk.pop()
    bx = not b[v]
    for x in T[v]:
        if b[x] is None:
            b[x] = bx
            stk.append(x)
print(min(b.count(True), b.count(False)))
0