結果
問題 | No.977 アリス仕掛けの摩天楼 |
ユーザー | GrayCoder |
提出日時 | 2020-01-31 23:15:21 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 718 bytes |
コンパイル時間 | 122 ms |
コンパイル使用メモリ | 11,784 KB |
実行使用メモリ | 122,228 KB |
最終ジャッジ日時 | 2023-10-17 12:24:09 |
合計ジャッジ時間 | 25,272 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | AC | 748 ms
53,556 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 783 ms
53,560 KB |
testcase_07 | AC | 763 ms
53,568 KB |
testcase_08 | AC | 768 ms
53,564 KB |
testcase_09 | WA | - |
testcase_10 | AC | 752 ms
53,564 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 785 ms
55,048 KB |
testcase_15 | AC | 782 ms
55,044 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 812 ms
57,052 KB |
testcase_20 | AC | 839 ms
60,528 KB |
testcase_21 | AC | 923 ms
66,120 KB |
testcase_22 | AC | 958 ms
70,832 KB |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
ソースコード
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 = [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()