結果

問題 No.1719 Tree and Permutation
ユーザー tamato
提出日時 2021-10-22 23:23:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 393 ms / 2,000 ms
コード長 590 bytes
コンパイル時間 1,156 ms
コンパイル使用メモリ 82,600 KB
実行使用メモリ 127,744 KB
最終ジャッジ日時 2024-09-23 07:53:38
合計ジャッジ時間 3,151 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 6
権限があれば一括ダウンロードができます

ソースコード

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