結果
問題 | No.2202 贅沢てりたまチキン |
ユーザー | Hydru |
提出日時 | 2023-02-03 21:36:02 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 467 ms / 2,000 ms |
コード長 | 1,392 bytes |
コンパイル時間 | 701 ms |
コンパイル使用メモリ | 86,844 KB |
実行使用メモリ | 83,920 KB |
最終ジャッジ日時 | 2023-09-15 17:11:59 |
合計ジャッジ時間 | 5,719 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 71 ms
71,336 KB |
testcase_01 | AC | 70 ms
71,436 KB |
testcase_02 | AC | 69 ms
71,324 KB |
testcase_03 | AC | 68 ms
71,264 KB |
testcase_04 | AC | 68 ms
71,276 KB |
testcase_05 | AC | 68 ms
71,492 KB |
testcase_06 | AC | 67 ms
71,272 KB |
testcase_07 | AC | 68 ms
71,380 KB |
testcase_08 | AC | 67 ms
71,420 KB |
testcase_09 | AC | 67 ms
71,548 KB |
testcase_10 | AC | 71 ms
74,608 KB |
testcase_11 | AC | 70 ms
71,068 KB |
testcase_12 | AC | 71 ms
71,224 KB |
testcase_13 | AC | 69 ms
71,332 KB |
testcase_14 | AC | 188 ms
81,424 KB |
testcase_15 | AC | 187 ms
81,456 KB |
testcase_16 | AC | 183 ms
80,500 KB |
testcase_17 | AC | 187 ms
80,688 KB |
testcase_18 | AC | 146 ms
81,860 KB |
testcase_19 | AC | 144 ms
80,224 KB |
testcase_20 | AC | 212 ms
81,632 KB |
testcase_21 | AC | 213 ms
81,348 KB |
testcase_22 | AC | 193 ms
79,084 KB |
testcase_23 | AC | 274 ms
80,108 KB |
testcase_24 | AC | 234 ms
78,892 KB |
testcase_25 | AC | 467 ms
83,920 KB |
testcase_26 | AC | 202 ms
81,756 KB |
testcase_27 | AC | 188 ms
81,164 KB |
ソースコード
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,m=map(int,input().split()) U=UnionFind(2*n) for _ in range(m): a,b=map(lambda x:int(x)-1,input().split()) U.union(a,b+n) U.union(a+n,b) for i in range(n): if not U.same(i,i+n): print("No") exit() print("Yes")