結果
| 問題 |
No.1424 Ultrapalindrome
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2021-03-12 21:35:23 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 579 bytes |
| コンパイル時間 | 139 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 31,872 KB |
| 最終ジャッジ日時 | 2024-10-14 11:47:12 |
| 合計ジャッジ時間 | 6,723 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 18 WA * 11 |
ソースコード
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]
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:
True
else:
print("No")
break
else:
print("Yes")
titia