結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー ああいいああいい
提出日時 2021-12-05 18:27:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 771 bytes
コンパイル時間 197 ms
コンパイル使用メモリ 10,980 KB
実行使用メモリ 27,952 KB
最終ジャッジ日時 2023-09-21 14:53:33
合計ジャッジ時間 8,641 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,204 KB
testcase_01 AC 16 ms
7,832 KB
testcase_02 AC 16 ms
7,936 KB
testcase_03 AC 16 ms
7,836 KB
testcase_04 AC 16 ms
7,804 KB
testcase_05 AC 15 ms
7,824 KB
testcase_06 AC 16 ms
7,944 KB
testcase_07 AC 16 ms
7,812 KB
testcase_08 AC 16 ms
7,804 KB
testcase_09 AC 16 ms
7,840 KB
testcase_10 AC 16 ms
7,852 KB
testcase_11 AC 17 ms
7,828 KB
testcase_12 AC 17 ms
8,352 KB
testcase_13 AC 76 ms
10,292 KB
testcase_14 AC 442 ms
10,192 KB
testcase_15 AC 424 ms
10,324 KB
testcase_16 AC 73 ms
10,132 KB
testcase_17 AC 64 ms
10,048 KB
testcase_18 AC 233 ms
14,188 KB
testcase_19 AC 169 ms
14,228 KB
testcase_20 AC 288 ms
17,744 KB
testcase_21 AC 444 ms
22,756 KB
testcase_22 AC 588 ms
26,904 KB
testcase_23 RE -
testcase_24 AC 761 ms
27,860 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):
    if get(i) == get(j):
        return
    union[get(i)] = get(j)
    union[i] = get(j)
    
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