結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-04-16 13:11:12
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 810 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 86,948 KB
実行使用メモリ 79,740 KB
最終ジャッジ日時 2023-08-26 17:39:06
合計ジャッジ時間 6,006 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
70,984 KB
testcase_01 AC 72 ms
71,196 KB
testcase_02 AC 71 ms
71,260 KB
testcase_03 AC 74 ms
71,476 KB
testcase_04 AC 71 ms
71,220 KB
testcase_05 AC 70 ms
71,240 KB
testcase_06 AC 72 ms
71,184 KB
testcase_07 AC 73 ms
71,352 KB
testcase_08 AC 72 ms
71,360 KB
testcase_09 AC 74 ms
71,144 KB
testcase_10 WA -
testcase_11 AC 73 ms
71,292 KB
testcase_12 AC 72 ms
71,288 KB
testcase_13 AC 179 ms
78,044 KB
testcase_14 AC 146 ms
78,140 KB
testcase_15 AC 144 ms
78,412 KB
testcase_16 AC 141 ms
77,788 KB
testcase_17 AC 145 ms
77,716 KB
testcase_18 AC 163 ms
77,936 KB
testcase_19 WA -
testcase_20 AC 213 ms
78,828 KB
testcase_21 AC 238 ms
78,592 KB
testcase_22 AC 268 ms
79,408 KB
testcase_23 AC 254 ms
79,740 KB
testcase_24 AC 227 ms
79,704 KB
testcase_25 AC 248 ms
79,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class Unionfind:
     
    def __init__(self,n):
        self.uf = [-1]*n
 
    def find(self,x):
        if self.uf[x] < 0:
            return x
        else:
            self.uf[x] = self.find(self.uf[x])
            return self.uf[x]
 
    def same(self,x,y):
        return self.find(x) == self.find(y)
 
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.uf[x] > self.uf[y]:
            x,y = y,x
        self.uf[x] += self.uf[y]
        self.uf[y] = x
        return True
 
    def size(self,x):
        x = self.find(x)
        return -self.uf[x]

n = int(input())
uf = Unionfind(n)
for _ in range(n-1):
    u,v = map(int,input().split())
    uf.union(u,v)

if uf.size(0) == n:
    print("Bob")
else:
    print("Alice")
0