結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー flippergo
提出日時 2020-12-30 11:36:29
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 576 bytes
コンパイル時間 655 ms
コンパイル使用メモリ 81,848 KB
実行使用メモリ 94,468 KB
最終ジャッジ日時 2024-10-06 23:11:52
合計ジャッジ時間 4,865 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
N = int(input())
G = {i:[] for i in range(N)}
for _ in range(N-1):
    u,v = map(int,input().split())
    G[u].append(v)
    G[v].append(u)
col = [-1 for _ in range(N)]
cnt = 0
for i in range(N):
    if col[i]<0:
        col[i] = cnt
        que = deque([i])
        while que:
            x = que.popleft()
            for y in G[x]:
                if col[y]<0:
                    col[y]=cnt
                    que.append(y)
        cnt += 1
if N==2:
    print("Bob")
else:
    if cnt>=2:
        print("Alice")
    else:
        print("Bob")
0