結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー mokraimokrai
提出日時 2020-01-31 23:29:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 809 bytes
コンパイル時間 353 ms
コンパイル使用メモリ 11,820 KB
実行使用メモリ 795,244 KB
最終ジャッジ日時 2023-10-17 12:50:38
合計ジャッジ時間 5,473 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 30 ms
10,156 KB
testcase_04 AC 30 ms
10,156 KB
testcase_05 AC 30 ms
10,156 KB
testcase_06 AC 30 ms
10,156 KB
testcase_07 AC 30 ms
10,172 KB
testcase_08 AC 30 ms
10,220 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 30 ms
10,220 KB
testcase_12 AC 31 ms
10,224 KB
testcase_13 MLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

B = [0] * N

G = []
for i in range(N):
    G.append([False] * N)

for i in range(N-1):
    u, v = list(map(int, input().split()))
    B[u] += 1
    B[v] += 1
    G[u][v] = True
    G[v][u] = True

# print(G)

no_b = 0
for bi in B:
    if bi == 0:
        no_b += 1

# print(B)

if no_b == 0:
    visited = [False] * N
    def dfs(v):
        if visited[v]:
            return
        visited[v] = True
        edges = G[v]
        for i, e in enumerate(edges):
            if e:
                dfs(i) 

    dfs(0)
    print(visited)
    if all(visited):
        print('Bob')
    else:
        print('Alice')
elif no_b == 1:
    ans = True
    for bi in B:
        if bi != 2:
            ans = False
    if ans:
        print('Bob')
    else:
        print("Alice")
else:
    print("Alice")
0