結果

問題 No.806 木を道に
ユーザー tamatotamato
提出日時 2020-02-27 09:14:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 182 ms / 2,000 ms
コード長 396 bytes
コンパイル時間 176 ms
コンパイル使用メモリ 82,336 KB
実行使用メモリ 87,852 KB
最終ジャッジ日時 2024-04-21 16:47:12
合計ジャッジ時間 4,360 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
53,504 KB
testcase_01 AC 52 ms
53,632 KB
testcase_02 AC 51 ms
53,504 KB
testcase_03 AC 51 ms
53,504 KB
testcase_04 AC 52 ms
53,248 KB
testcase_05 AC 53 ms
53,504 KB
testcase_06 AC 52 ms
53,504 KB
testcase_07 AC 55 ms
53,888 KB
testcase_08 AC 56 ms
53,248 KB
testcase_09 AC 51 ms
53,376 KB
testcase_10 AC 97 ms
78,464 KB
testcase_11 AC 97 ms
78,208 KB
testcase_12 AC 162 ms
84,608 KB
testcase_13 AC 139 ms
82,944 KB
testcase_14 AC 161 ms
84,608 KB
testcase_15 AC 167 ms
84,608 KB
testcase_16 AC 103 ms
78,832 KB
testcase_17 AC 156 ms
84,224 KB
testcase_18 AC 77 ms
70,144 KB
testcase_19 AC 102 ms
78,416 KB
testcase_20 AC 152 ms
83,876 KB
testcase_21 AC 124 ms
80,000 KB
testcase_22 AC 180 ms
85,480 KB
testcase_23 AC 182 ms
85,376 KB
testcase_24 AC 91 ms
80,000 KB
testcase_25 AC 106 ms
84,192 KB
testcase_26 AC 84 ms
79,360 KB
testcase_27 AC 119 ms
87,852 KB
testcase_28 AC 62 ms
64,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    import sys
    from collections import deque
    input = sys.stdin.readline

    N = int(input())
    adj = [[] for _ in range(N+1)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        adj[a].append(b)
        adj[b].append(a)

    ans = -2
    for v in range(1, N+1):
        ans += (len(adj[v]) == 1)
    print(ans)


if __name__ == '__main__':
    main()
0