結果
問題 | No.977 アリス仕掛けの摩天楼 |
ユーザー | aqua_tenhou |
提出日時 | 2020-09-15 21:59:46 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,334 bytes |
コンパイル時間 | 840 ms |
コンパイル使用メモリ | 11,064 KB |
実行使用メモリ | 10,324 KB |
最終ジャッジ日時 | 2023-09-04 02:58:12 |
合計ジャッジ時間 | 5,068 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 17 ms
8,360 KB |
testcase_01 | AC | 17 ms
8,256 KB |
testcase_02 | AC | 17 ms
8,308 KB |
testcase_03 | AC | 17 ms
8,220 KB |
testcase_04 | AC | 17 ms
8,208 KB |
testcase_05 | AC | 17 ms
8,244 KB |
testcase_06 | AC | 17 ms
8,380 KB |
testcase_07 | AC | 17 ms
8,392 KB |
testcase_08 | AC | 17 ms
8,268 KB |
testcase_09 | AC | 17 ms
8,132 KB |
testcase_10 | WA | - |
testcase_11 | AC | 17 ms
8,216 KB |
testcase_12 | AC | 17 ms
8,224 KB |
testcase_13 | AC | 49 ms
8,424 KB |
testcase_14 | AC | 48 ms
8,412 KB |
testcase_15 | AC | 48 ms
8,416 KB |
testcase_16 | AC | 48 ms
8,408 KB |
testcase_17 | AC | 47 ms
8,528 KB |
testcase_18 | AC | 110 ms
8,756 KB |
testcase_19 | WA | - |
testcase_20 | AC | 176 ms
9,368 KB |
testcase_21 | AC | 271 ms
9,856 KB |
testcase_22 | AC | 340 ms
10,324 KB |
testcase_23 | AC | 351 ms
9,864 KB |
testcase_24 | AC | 340 ms
10,128 KB |
testcase_25 | AC | 353 ms
9,772 KB |
ソースコード
#UnionFind class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.parents[x] > self.parents[y]: x, y = y, x self.parents[x] += self.parents[y] self.parents[y] = x def size(self, x): return -self.parents[self.find(x)] def same(self, x, y): return self.find(x) == self.find(y) def members(self, x): root = self.find(x) return [i for i in range(self.n) if self.find(i) == root] def roots(self): return [i for i, x in enumerate(self.parents) if x < 0] def group_count(self): return len(self.roots()) def all_group_members(self): return {r: self.members(r) for r in self.roots()} def __str__(self): return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots()) n = int(input()) uf = UnionFind(n) for _ in range(n-1): v,w = map(int,input().split()) uf.union(v,w) if uf.size(0) == n: print("Bob") else: print("Alice")