結果

問題 No.1719 Tree and Permutation
ユーザー 👑 tamatotamato
提出日時 2021-10-22 23:23:44
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 333 ms / 2,000 ms
コード長 590 bytes
コンパイル時間 365 ms
コンパイル使用メモリ 81,828 KB
実行使用メモリ 127,432 KB
最終ジャッジ日時 2023-10-24 15:28:36
合計ジャッジ時間 2,682 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,680 KB
testcase_01 AC 161 ms
76,600 KB
testcase_02 AC 155 ms
76,232 KB
testcase_03 AC 333 ms
127,432 KB
testcase_04 AC 288 ms
118,732 KB
testcase_05 AC 298 ms
115,396 KB
testcase_06 AC 292 ms
120,124 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.buffer.readline
    
    for _ in range(int(input())):
        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)
        
        leaf_num = 0
        for v in range(1, N+1):
            if len(adj[v]) == 1:
                leaf_num += 1
        if leaf_num * 2 >= N:
            print("Yes")
        else:
            print("No")


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