結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー flippergoflippergo
提出日時 2020-12-30 11:36:29
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 576 bytes
コンパイル時間 706 ms
コンパイル使用メモリ 82,160 KB
実行使用メモリ 94,492 KB
最終ジャッジ日時 2024-04-16 08:09:24
合計ジャッジ時間 5,238 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
54,864 KB
testcase_01 AC 44 ms
54,188 KB
testcase_02 AC 44 ms
54,656 KB
testcase_03 AC 44 ms
53,956 KB
testcase_04 AC 44 ms
54,776 KB
testcase_05 AC 43 ms
53,992 KB
testcase_06 AC 44 ms
54,192 KB
testcase_07 AC 45 ms
54,628 KB
testcase_08 AC 45 ms
54,464 KB
testcase_09 AC 45 ms
54,924 KB
testcase_10 WA -
testcase_11 AC 45 ms
55,132 KB
testcase_12 AC 48 ms
55,320 KB
testcase_13 AC 105 ms
77,996 KB
testcase_14 AC 107 ms
78,124 KB
testcase_15 AC 108 ms
78,188 KB
testcase_16 AC 106 ms
78,000 KB
testcase_17 AC 104 ms
78,184 KB
testcase_18 AC 141 ms
81,460 KB
testcase_19 WA -
testcase_20 AC 192 ms
85,488 KB
testcase_21 AC 256 ms
90,580 KB
testcase_22 AC 302 ms
94,192 KB
testcase_23 AC 306 ms
94,464 KB
testcase_24 AC 283 ms
94,392 KB
testcase_25 AC 303 ms
94,492 KB
権限があれば一括ダウンロードができます

ソースコード

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