結果

問題 No.1424 Ultrapalindrome
ユーザー brthyyjpbrthyyjp
提出日時 2021-03-12 22:29:32
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 618 bytes
コンパイル時間 836 ms
コンパイル使用メモリ 82,308 KB
実行使用メモリ 96,828 KB
最終ジャッジ日時 2024-04-22 13:32:42
合計ジャッジ時間 8,209 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
53,632 KB
testcase_01 AC 43 ms
54,016 KB
testcase_02 AC 42 ms
54,024 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 43 ms
54,016 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 145 ms
82,432 KB
testcase_12 AC 175 ms
83,464 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 128 ms
81,636 KB
testcase_17 AC 146 ms
82,468 KB
testcase_18 AC 162 ms
80,812 KB
testcase_19 AC 134 ms
82,560 KB
testcase_20 AC 73 ms
72,704 KB
testcase_21 AC 114 ms
81,756 KB
testcase_22 AC 100 ms
80,512 KB
testcase_23 AC 74 ms
66,816 KB
testcase_24 AC 72 ms
72,696 KB
testcase_25 AC 71 ms
72,216 KB
testcase_26 AC 146 ms
83,552 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 990 ms
88,540 KB
testcase_31 AC 1,002 ms
96,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

n = int(input())
g = [[] for i in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    g[a].append(b)
    g[b].append(a)
from collections import deque
q = deque([])
for v in range(n):
    if len(g[v]) == 1:
        q.append(v)
while n > 2:
    l = len(q)
    n -= l
    for i in range(l):
        v = q.popleft()
        for u in g[v]:
            g[u].remove(v)
            if len(g[u]) == 1:
                q.append(u)
#print(list(q))
if len(q) == 1:
    print('Yes')
else:
    print('No')
0