結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー GrayCoderGrayCoder
提出日時 2020-01-31 23:03:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 626 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 11,848 KB
実行使用メモリ 117,296 KB
最終ジャッジ日時 2023-10-17 11:58:10
合計ジャッジ時間 26,723 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 736 ms
50,884 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 749 ms
50,884 KB
testcase_07 AC 741 ms
50,892 KB
testcase_08 AC 731 ms
50,888 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 758 ms
52,368 KB
testcase_15 AC 763 ms
52,368 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 839 ms
60,000 KB
testcase_21 AC 907 ms
65,840 KB
testcase_22 AC 937 ms
70,228 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix
from itertools import chain
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')
    if x == 2:
        num = list(chain.from_iterable(UV))
        if (min(num), max(num)) in UV:
            print('Bob')
    else:
        print('Alice')


main()
0