結果

問題 No.1424 Ultrapalindrome
ユーザー titiatitia
提出日時 2021-03-12 21:36:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 605 bytes
コンパイル時間 254 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 32,000 KB
最終ジャッジ日時 2024-04-22 12:24:41
合計ジャッジ時間 6,991 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,752 KB
testcase_01 AC 30 ms
10,752 KB
testcase_02 AC 31 ms
10,752 KB
testcase_03 WA -
testcase_04 AC 30 ms
10,624 KB
testcase_05 AC 30 ms
10,880 KB
testcase_06 AC 31 ms
10,752 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 350 ms
24,960 KB
testcase_10 AC 338 ms
24,832 KB
testcase_11 AC 239 ms
20,864 KB
testcase_12 AC 333 ms
24,192 KB
testcase_13 AC 98 ms
14,464 KB
testcase_14 AC 272 ms
21,632 KB
testcase_15 AC 31 ms
10,880 KB
testcase_16 AC 208 ms
19,584 KB
testcase_17 AC 259 ms
21,120 KB
testcase_18 AC 175 ms
17,792 KB
testcase_19 AC 276 ms
21,120 KB
testcase_20 AC 79 ms
13,184 KB
testcase_21 AC 220 ms
20,864 KB
testcase_22 AC 142 ms
16,128 KB
testcase_23 AC 51 ms
12,032 KB
testcase_24 AC 78 ms
13,568 KB
testcase_25 AC 74 ms
13,312 KB
testcase_26 AC 296 ms
23,168 KB
testcase_27 WA -
testcase_28 AC 324 ms
31,872 KB
testcase_29 WA -
testcase_30 AC 306 ms
27,264 KB
testcase_31 AC 311 ms
30,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N=int(input())
E=[[] for i in range(N)]
ED=[0]*N
for i in range(N-1):
    x,y=map(int,input().split())
    E[x-1].append(y-1)
    E[y-1].append(x-1)
    ED[x-1]+=1
    ED[y-1]+=1

for i in range(N):
    if ED[i]==1:
        Q=[i]
        init=i
        break

L=[0]*N
while Q:
    x=Q.pop()
    for to in E[x]:
        if L[to]==0:
            L[to]=L[x]+1
            Q.append(to)

flag=1
MAX=max(L)
for i in range(N):
    if ED[i]==1:
        if L[i]==MAX or i==init:
            True
        else:
            print("No")
            break
else:
    print("Yes")
0