結果
問題 |
No.977 アリス仕掛けの摩天楼
|
ユーザー |
|
提出日時 | 2023-10-31 11:17:17 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 691 bytes |
コンパイル時間 | 486 ms |
コンパイル使用メモリ | 82,368 KB |
実行使用メモリ | 100,976 KB |
最終ジャッジ日時 | 2024-09-25 17:33:22 |
合計ジャッジ時間 | 4,931 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 RE * 5 |
ソースコード
N = int(input()) UV = [list(map(int, input().split())) for _ in range(N-1)] comp = [-1] * N compn = [0] * N G = [[] for _ in range(N)] for i in range(N-1): u, v = UV[i] G[u].append(v) G[v].append(u) compn[u] += 1 compn[v] += 1 def dfs(now): for nxt in G[now]: if comp[nxt] != -1: continue comp[nxt] = comp[now] dfs(nxt) cnt = 0 for i in range(N): if comp[i] != -1: continue cnt += 1 comp[i] = cnt dfs(i) if max(comp) == 1: print('Bob') elif max(comp) >= 3: print('Alice') else: if all([False if x == 1 else True for x in compn]): print('Bob') else: print('Alice')