結果
問題 |
No.977 アリス仕掛けの摩天楼
|
ユーザー |
|
提出日時 | 2020-02-20 20:01:36 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 605 bytes |
コンパイル時間 | 238 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 14,848 KB |
最終ジャッジ日時 | 2024-10-08 19:09:15 |
合計ジャッジ時間 | 5,176 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 WA * 2 |
ソースコード
class UnionFind: def __init__(self, n): self.parent = [i for i in range(n)] def find(self, x): if self.parent[x] == x: return x self.parent[x] = self.find(self.parent[x]) return self.parent[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return self.parent[x] = y N = int(input()) uf = UnionFind(N) for i in range(N-1): u, v = map(int, input().split()) uf.union(u, v) first = uf.find(0) bob = all(uf.find(i) == first for i in range(1, N)) print('Bob' if bob else 'Alice')