結果
問題 | No.977 アリス仕掛けの摩天楼 |
ユーザー |
![]() |
提出日時 | 2020-01-31 21:43:35 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 894 bytes |
コンパイル時間 | 92 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 13,696 KB |
最終ジャッジ日時 | 2024-09-17 07:33:00 |
合計ジャッジ時間 | 3,977 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 WA * 2 |
ソースコード
import sys;sys.setrecursionlimit(10**9)class UnionFind():def __init__(self,n):self.n=[-1]*nself.r=[0]*ndef Find_Root(self,x):if self.n[x]<0:return xelse:self.n[x]=self.Find_Root(self.n[x])return self.n[x]def Unite(self,x,y):x=self.Find_Root(x)y=self.Find_Root(y)if x==y:returnelif self.r[x]>self.r[y]:self.n[x]+=self.n[y]self.n[y]=xelse:self.n[y]+=self.n[x]self.n[x]=yif self.r[x]==self.r[y]:self.r[y]+=1def Root_Same(self,x,y):return self.Find_Root(x)==self.Find_Root(y)def Count(self,x):return -self.n[self.Find_Root(x)]def Is_Root(self,x):return self.Find_Root(x)==xn=int(input())u=UnionFind(n)for i in range(n-1):a,b=map(int,input().split())u.Unite(a,b)for i in range(1,n):if not u.Root_Same(0,i):print("Alice");exit()print("Bob")