結果
問題 | No.977 アリス仕掛けの摩天楼 |
ユーザー | zaki_chemtech |
提出日時 | 2020-07-10 20:51:06 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 218 ms / 2,000 ms |
コード長 | 655 bytes |
コンパイル時間 | 147 ms |
コンパイル使用メモリ | 82,224 KB |
実行使用メモリ | 89,120 KB |
最終ジャッジ日時 | 2024-04-19 15:07:01 |
合計ジャッジ時間 | 3,344 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 37 ms
54,376 KB |
testcase_01 | AC | 35 ms
55,312 KB |
testcase_02 | AC | 36 ms
55,048 KB |
testcase_03 | AC | 37 ms
54,376 KB |
testcase_04 | AC | 40 ms
54,112 KB |
testcase_05 | AC | 38 ms
55,232 KB |
testcase_06 | AC | 36 ms
54,340 KB |
testcase_07 | AC | 38 ms
54,316 KB |
testcase_08 | AC | 42 ms
54,300 KB |
testcase_09 | AC | 40 ms
54,936 KB |
testcase_10 | AC | 41 ms
54,568 KB |
testcase_11 | AC | 39 ms
54,524 KB |
testcase_12 | AC | 38 ms
54,512 KB |
testcase_13 | AC | 92 ms
77,420 KB |
testcase_14 | AC | 83 ms
77,204 KB |
testcase_15 | AC | 95 ms
77,596 KB |
testcase_16 | AC | 99 ms
77,396 KB |
testcase_17 | AC | 101 ms
77,668 KB |
testcase_18 | AC | 118 ms
80,328 KB |
testcase_19 | AC | 115 ms
80,436 KB |
testcase_20 | AC | 129 ms
82,456 KB |
testcase_21 | AC | 153 ms
85,384 KB |
testcase_22 | AC | 184 ms
88,164 KB |
testcase_23 | AC | 217 ms
88,820 KB |
testcase_24 | AC | 216 ms
88,940 KB |
testcase_25 | AC | 218 ms
89,120 KB |
ソースコード
from collections import deque n = int(input()) root = [[] for i in range(n)] for _ in range(n-1): a, b = (int(x) for x in input().split()) root[b].append(a) root[a].append(b) stack=deque([0]) check = [-1]*n check[0] = 1 while len(stack)>0: v = stack.popleft() for i in root[v]: if check[i] == -1: check[i]=check[v]+1 stack.append(i) if n == 2 or -1 not in check: print('Bob') else: count_1 = check.count(-1) count_ren = 0 for i in root: if len(i) < 2: count_ren += 1 if count_1 < 2 and count_ren < 2: print('Bob') else: print('Alice')