結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー takakintakakin
提出日時 2020-05-15 14:15:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 281 ms / 2,000 ms
コード長 654 bytes
コンパイル時間 102 ms
コンパイル使用メモリ 11,876 KB
実行使用メモリ 12,952 KB
最終ジャッジ日時 2023-10-19 03:23:49
合計ジャッジ時間 3,602 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,136 KB
testcase_01 AC 29 ms
10,136 KB
testcase_02 AC 30 ms
10,136 KB
testcase_03 AC 30 ms
10,136 KB
testcase_04 AC 30 ms
10,136 KB
testcase_05 AC 29 ms
10,136 KB
testcase_06 AC 30 ms
10,136 KB
testcase_07 AC 30 ms
10,136 KB
testcase_08 AC 30 ms
10,136 KB
testcase_09 AC 29 ms
10,136 KB
testcase_10 AC 30 ms
10,136 KB
testcase_11 AC 30 ms
10,136 KB
testcase_12 AC 30 ms
10,136 KB
testcase_13 AC 52 ms
10,372 KB
testcase_14 AC 51 ms
10,328 KB
testcase_15 AC 51 ms
10,332 KB
testcase_16 AC 52 ms
10,372 KB
testcase_17 AC 52 ms
10,420 KB
testcase_18 AC 98 ms
10,876 KB
testcase_19 AC 101 ms
10,872 KB
testcase_20 AC 148 ms
11,424 KB
testcase_21 AC 222 ms
12,368 KB
testcase_22 AC 281 ms
12,952 KB
testcase_23 AC 279 ms
12,496 KB
testcase_24 AC 274 ms
12,500 KB
testcase_25 AC 281 ms
12,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
par=[-1]*n

def find(x):
  if par[x]<0:
    return x
  else:
    par[x]=find(par[x])
    return par[x]

def unite(x,y):
  x=find(x)
  y=find(y)
  if x==y:
    return False
  else:
    if par[x]>par[y]:
      x,y=y,x
    par[x]+=par[y]
    par[y]=x
    return True

def same(x,y):
  return find(x)==find(y)

def size(x):
  return -par[find(x)]

C=[0]*n
for _ in range(n-1):
  u,v=map(int,input().split())
  unite(u,v)
  C[u]+=1
  C[v]+=1
for i in range(n):
  find(i)
if -min(par)==n:
  print("Bob")
elif -min(par)==n-1 and max(C)==2 and min(C)==0:
  print("Bob")
else:
  print("Alice")
0