結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー FeLvi_zzzFeLvi_zzz
提出日時 2020-02-08 08:13:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 622 bytes
コンパイル時間 656 ms
コンパイル使用メモリ 11,912 KB
実行使用メモリ 14,184 KB
最終ジャッジ日時 2023-10-26 00:44:46
合計ジャッジ時間 4,564 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
10,168 KB
testcase_01 AC 31 ms
10,168 KB
testcase_02 AC 30 ms
10,168 KB
testcase_03 AC 30 ms
10,168 KB
testcase_04 AC 30 ms
10,168 KB
testcase_05 AC 29 ms
10,168 KB
testcase_06 AC 31 ms
10,168 KB
testcase_07 AC 30 ms
10,168 KB
testcase_08 AC 30 ms
10,168 KB
testcase_09 AC 30 ms
10,168 KB
testcase_10 WA -
testcase_11 AC 30 ms
10,168 KB
testcase_12 AC 30 ms
10,168 KB
testcase_13 AC 65 ms
10,572 KB
testcase_14 AC 66 ms
10,600 KB
testcase_15 AC 67 ms
10,600 KB
testcase_16 AC 66 ms
10,572 KB
testcase_17 AC 66 ms
10,568 KB
testcase_18 AC 141 ms
11,440 KB
testcase_19 WA -
testcase_20 AC 214 ms
12,156 KB
testcase_21 AC 326 ms
13,204 KB
testcase_22 AC 420 ms
14,004 KB
testcase_23 AC 463 ms
14,184 KB
testcase_24 AC 433 ms
14,184 KB
testcase_25 AC 458 ms
14,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

import sys
sys.setrecursionlimit(10**6)

class UnionFind():
  def __init__(self, n):
    self.par = [i for i in range(n)]

  def root(self, x):
    if self.par[x] == x:
      return x
    else:
      self.par[x] = self.root(self.par[x])
      return self.par[x]
  
  def unite(self, x, y):
    x = self.root(x)
    y = self.root(y)
    self.par[y] = x

  def same(self, x, y):
    return self.root(x) == self.root(y)

uf = UnionFind(N)
for i in range(N-1):
  u, v = map(int, input().split())
  uf.unite(u, v)

ans = set()
for i in range(N):
  ans.add(uf.root(i))
print("Alice" if len(ans) > 1 else "Bob")
0