結果
問題 | No.977 アリス仕掛けの摩天楼 |
ユーザー | GrayCoder |
提出日時 | 2020-01-31 23:16:35 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 692 bytes |
コンパイル時間 | 463 ms |
コンパイル使用メモリ | 11,808 KB |
実行使用メモリ | 71,776 KB |
最終ジャッジ日時 | 2023-10-17 12:26:42 |
合計ジャッジ時間 | 23,866 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 784 ms
53,444 KB |
testcase_01 | AC | 712 ms
53,564 KB |
testcase_02 | AC | 710 ms
53,564 KB |
testcase_03 | AC | 713 ms
53,564 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 710 ms
53,568 KB |
testcase_07 | AC | 710 ms
53,576 KB |
testcase_08 | AC | 709 ms
53,572 KB |
testcase_09 | AC | 741 ms
53,740 KB |
testcase_10 | AC | 716 ms
53,572 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 731 ms
55,052 KB |
testcase_15 | AC | 728 ms
55,052 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 775 ms
57,040 KB |
testcase_20 | AC | 815 ms
59,984 KB |
testcase_21 | AC | 880 ms
66,108 KB |
testcase_22 | AC | 906 ms
70,820 KB |
testcase_23 | AC | 917 ms
71,768 KB |
testcase_24 | WA | - |
testcase_25 | AC | 926 ms
71,776 KB |
ソースコード
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: num = [0] * N for u, v in UV: num[u] += 1 num[v] += 1 for n in num: if n not in (0, 2): print('Alice') print('Bob') else: print('Alice') main()