結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー ああいいああいい
提出日時 2021-12-05 18:30:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 776 bytes
コンパイル時間 79 ms
コンパイル使用メモリ 11,076 KB
実行使用メモリ 28,056 KB
最終ジャッジ日時 2023-09-21 14:53:40
合計ジャッジ時間 6,148 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,144 KB
testcase_01 AC 16 ms
7,868 KB
testcase_02 AC 15 ms
7,816 KB
testcase_03 AC 16 ms
7,816 KB
testcase_04 AC 16 ms
7,868 KB
testcase_05 AC 16 ms
7,988 KB
testcase_06 AC 16 ms
7,852 KB
testcase_07 AC 17 ms
7,852 KB
testcase_08 AC 16 ms
7,728 KB
testcase_09 AC 16 ms
7,920 KB
testcase_10 AC 16 ms
7,776 KB
testcase_11 AC 16 ms
7,776 KB
testcase_12 AC 16 ms
8,336 KB
testcase_13 AC 65 ms
10,284 KB
testcase_14 AC 236 ms
10,172 KB
testcase_15 AC 229 ms
10,344 KB
testcase_16 AC 64 ms
10,128 KB
testcase_17 AC 61 ms
10,032 KB
testcase_18 AC 177 ms
14,184 KB
testcase_19 AC 161 ms
14,072 KB
testcase_20 AC 259 ms
17,788 KB
testcase_21 AC 418 ms
22,760 KB
testcase_22 AC 550 ms
26,864 KB
testcase_23 RE -
testcase_24 AC 602 ms
27,704 KB
testcase_25 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
u = [0] * (N-1)
v = [0] * (N-1)
for i in range(N-1):
    u[i],v[i] = list(map(int,input().split()))

tree = [[] for _ in range(N)]
union = [i for i in range(N)]

def get(i):
    if union[i] == i:
        return i
    else:
        return get(union[i])
def renketu(i,j):
    s = get(i)
    t = get(j)
    if s == t:
        return
    union[s] = t
    union[i] = t
    
for i in range(N-1):
    tree[u[i]].append(v[i])
    tree[v[i]].append(u[i])

    renketu(u[i],v[i])

cone = 0
for i in range(N):
    if union[i] == i:
        cone += 1
num = 0
for i in range(N):
    if len(tree[i]) == 1:
        num += 1

    
A = 'Alice'
B = 'Bob'
if cone == 1:
    print(B)
elif cone >= 3:
    print(A)
else:
    if num > 0:
        print(A)
    else:
        print(B)
0