結果
| 問題 |
No.977 アリス仕掛けの摩天楼
|
| ユーザー |
|
| 提出日時 | 2020-01-31 23:15:21 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 718 bytes |
| コンパイル時間 | 82 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 76,436 KB |
| 最終ジャッジ日時 | 2024-09-17 10:33:06 |
| 合計ジャッジ時間 | 30,580 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 WA * 15 |
ソースコード
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()