結果

問題 No.1719 Tree and Permutation
ユーザー zkou
提出日時 2021-09-23 17:12:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 142 ms / 2,000 ms
コード長 337 bytes
コンパイル時間 147 ms
コンパイル使用メモリ 82,100 KB
実行使用メモリ 79,232 KB
最終ジャッジ日時 2024-09-23 03:49:22
合計ジャッジ時間 1,758 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

T = int(input())
for _ in range(T):
    N = int(input())
    deg = [0] * N
    for _ in range(N - 1):
        u, v = map(int, input().split())
        u -= 1; v -= 1
        deg[u] += 1
        deg[v] += 1
    print("Yes" if deg.count(1) * 2 >= N else "No")
    
0