結果
問題 |
No.977 アリス仕掛けの摩天楼
|
ユーザー |
![]() |
提出日時 | 2020-01-31 23:02:38 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 852 bytes |
コンパイル時間 | 94 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 30,640 KB |
最終ジャッジ日時 | 2024-09-17 10:07:10 |
合計ジャッジ時間 | 3,326 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 WA * 2 |
ソースコード
class UnionFind: def __init__(self, size): self.data = [-1] * size def find(self, x): if self.data[x] < 0: return x else: self.data[x] = self.find(self.data[x]) return self.data[x] def union(self, x, y): x, y = self.find(x), self.find(y) if x != y: if self.data[y] < self.data[x]: x, y = y, x self.data[x] += self.data[y] self.data[y] = x return (x != y) def same(self, x, y): return (self.find(x) == self.find(y)) def size(self, x): return -self.data[self.find(x)] N, *AB = map(int, open(0).read().split()) uf = UnionFind(N) for a, b in zip(*[iter(AB)] * 2): uf.union(a, b) C = len(set(uf.find(i) for i in range(N))) if C >= 2: print("Alice") else: print("Bob")