結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー GrayCoderGrayCoder
提出日時 2020-02-01 04:23:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 645 bytes
コンパイル時間 106 ms
コンパイル使用メモリ 11,920 KB
実行使用メモリ 71,244 KB
最終ジャッジ日時 2023-10-18 23:30:12
合計ジャッジ時間 24,859 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 753 ms
53,544 KB
testcase_01 AC 752 ms
53,600 KB
testcase_02 AC 752 ms
53,600 KB
testcase_03 AC 762 ms
53,600 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 751 ms
53,604 KB
testcase_07 AC 749 ms
53,624 KB
testcase_08 AC 758 ms
53,608 KB
testcase_09 AC 763 ms
53,776 KB
testcase_10 AC 748 ms
53,608 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 773 ms
55,088 KB
testcase_15 AC 766 ms
55,088 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 839 ms
57,088 KB
testcase_20 AC 866 ms
60,036 KB
testcase_21 AC 941 ms
65,700 KB
testcase_22 AC 956 ms
70,436 KB
testcase_23 AC 990 ms
71,228 KB
testcase_24 WA -
testcase_25 AC 990 ms
71,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    UV = [tuple(map(int, input().split())) for _ in [0] * (N - 1)]

    l = list(zip(*UV))
    d = [1] * len(UV)
    a = csr_matrix((d, (l[0], l[1])), (N, N))
    x = connected_components(a, return_labels=0)
    if x == 1:
        print('Bob')
    elif x == 2:
        cnt = [0] * N
        for u, v in UV:
            cnt[u] += 1
            cnt[v] += 1
        if cnt.count(2) == N - 1:
            print('Bob')
    else:
        print('Alice')


main()
0