結果
問題 | No.977 アリス仕掛けの摩天楼 |
ユーザー | TakoKurage |
提出日時 | 2020-01-31 23:05:00 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 863 bytes |
コンパイル時間 | 215 ms |
コンパイル使用メモリ | 12,004 KB |
実行使用メモリ | 33,248 KB |
最終ジャッジ日時 | 2023-10-17 12:00:25 |
合計ジャッジ時間 | 3,171 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 29 ms
10,188 KB |
testcase_01 | AC | 29 ms
10,188 KB |
testcase_02 | AC | 29 ms
10,188 KB |
testcase_03 | AC | 30 ms
10,188 KB |
testcase_04 | AC | 29 ms
10,188 KB |
testcase_05 | AC | 30 ms
10,188 KB |
testcase_06 | AC | 29 ms
10,188 KB |
testcase_07 | AC | 30 ms
10,196 KB |
testcase_08 | AC | 30 ms
10,200 KB |
testcase_09 | AC | 29 ms
10,200 KB |
testcase_10 | WA | - |
testcase_11 | AC | 30 ms
10,200 KB |
testcase_12 | AC | 30 ms
10,200 KB |
testcase_13 | AC | 45 ms
12,324 KB |
testcase_14 | AC | 44 ms
12,328 KB |
testcase_15 | AC | 45 ms
12,332 KB |
testcase_16 | AC | 45 ms
12,324 KB |
testcase_17 | AC | 46 ms
12,324 KB |
testcase_18 | AC | 77 ms
16,936 KB |
testcase_19 | WA | - |
testcase_20 | AC | 113 ms
21,320 KB |
testcase_21 | AC | 160 ms
27,584 KB |
testcase_22 | AC | 201 ms
31,948 KB |
testcase_23 | AC | 196 ms
33,248 KB |
testcase_24 | AC | 198 ms
33,248 KB |
testcase_25 | AC | 200 ms
33,248 KB |
ソースコード
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 N != 2 and C >= 2: print("Alice") else: print("Bob")