結果
問題 | No.1424 Ultrapalindrome |
ユーザー |
![]() |
提出日時 | 2021-03-17 19:41:41 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 635 bytes |
コンパイル時間 | 352 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 28,928 KB |
最終ジャッジ日時 | 2024-11-15 13:53:00 |
合計ジャッジ時間 | 11,929 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 WA * 1 RE * 4 |
ソースコード
leaf = set() def dfs(cv, pv, G, depth): is_leaf = True for nv in G[cv]: if nv == pv: continue dfs(nv, cv, G, depth + 1) is_leaf = False if is_leaf: leaf.add(depth) n = int(input()) G = [[] for i in range(n)] deg = [0 for i in range(n)] for i in range(n - 1): a, b = map(int, input().split()) a -= 1 b -= 1 deg[a] += 1 deg[b] += 1 G[a].append(b) G[b].append(a) root = [] for i in range(n): if deg[i] == 1 and len(root) <= 10: root.append(i) for i in root: dfs(i, -1, G, 0) if len(leaf) == 1: print("Yes") else: print("No")