結果
問題 |
No.977 アリス仕掛けの摩天楼
|
ユーザー |
|
提出日時 | 2020-03-19 04:37:01 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 645 bytes |
コンパイル時間 | 461 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 14,720 KB |
最終ジャッジ日時 | 2024-12-14 02:59:42 |
合計ジャッジ時間 | 4,480 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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 def main(): N = int(input()) uf = UnionFind(N) for _ in range(N-1): u, v = map(int, input().split()) uf.union(u, v) p = uf.find(0) bob = all(uf.find(i) == p for i in range(N)) print('Bob' if bob else 'Alice') main()