結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー NagisaNagisa
提出日時 2020-01-31 21:55:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 889 bytes
コンパイル時間 110 ms
コンパイル使用メモリ 11,984 KB
実行使用メモリ 28,412 KB
最終ジャッジ日時 2023-10-17 09:35:04
合計ジャッジ時間 3,794 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
10,148 KB
testcase_01 AC 26 ms
10,148 KB
testcase_02 AC 25 ms
10,148 KB
testcase_03 AC 26 ms
10,148 KB
testcase_04 AC 27 ms
10,148 KB
testcase_05 AC 25 ms
10,148 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 26 ms
10,156 KB
testcase_09 AC 25 ms
10,156 KB
testcase_10 AC 25 ms
10,156 KB
testcase_11 AC 25 ms
10,156 KB
testcase_12 AC 24 ms
10,156 KB
testcase_13 AC 42 ms
11,952 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 46 ms
11,976 KB
testcase_17 RE -
testcase_18 AC 87 ms
15,700 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 313 ms
28,408 KB
testcase_24 AC 293 ms
28,412 KB
testcase_25 AC 272 ms
28,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, math

def input():
    return sys.stdin.readline()[:-1]

def main():
    N = int(input())
    G = [[] for k in range(N)]
    F = [0 for k in range(N)]
    for k in range(N-1):
        u, v = map(int,input().split())
        u -= 1
        v -= 1
        G[u].append(v)
        G[v].append(u)
        F[u] += 1
        F[v] += 1
    V = [0 for k in range(N)]
    def dfs(ima):
        for e in G[ima]:
            if V[e] == 0:
                V[e] = 1
                dfs(e)
    dfs(0)
    c = 0
    for k in range(N):
        if V[k] == 1:
            c += 1
    if c == N:
        print("Bob")
    else:
        t, z = 0, 0
        for e in F:
            if e == 2:
                t += 1
            elif e == 0:
                z += 1
        if t == N-1 and z == 1:
            print("Bob")
        else:
            print("Alice")

if __name__ == '__main__':
    main()
0