結果
問題 | No.2202 贅沢てりたまチキン |
ユーザー | tamato |
提出日時 | 2023-02-03 21:26:01 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 295 ms / 2,000 ms |
コード長 | 1,380 bytes |
コンパイル時間 | 448 ms |
コンパイル使用メモリ | 87,260 KB |
実行使用メモリ | 85,404 KB |
最終ジャッジ日時 | 2023-09-15 16:47:49 |
合計ジャッジ時間 | 5,632 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 72 ms
71,328 KB |
testcase_01 | AC | 73 ms
71,364 KB |
testcase_02 | AC | 73 ms
71,272 KB |
testcase_03 | AC | 72 ms
71,544 KB |
testcase_04 | AC | 72 ms
71,332 KB |
testcase_05 | AC | 71 ms
71,536 KB |
testcase_06 | AC | 72 ms
71,420 KB |
testcase_07 | AC | 72 ms
71,364 KB |
testcase_08 | AC | 73 ms
71,128 KB |
testcase_09 | AC | 71 ms
71,320 KB |
testcase_10 | AC | 75 ms
77,848 KB |
testcase_11 | AC | 71 ms
71,368 KB |
testcase_12 | AC | 72 ms
71,324 KB |
testcase_13 | AC | 69 ms
71,328 KB |
testcase_14 | AC | 162 ms
83,328 KB |
testcase_15 | AC | 162 ms
83,280 KB |
testcase_16 | AC | 158 ms
83,464 KB |
testcase_17 | AC | 187 ms
83,808 KB |
testcase_18 | AC | 126 ms
80,464 KB |
testcase_19 | AC | 110 ms
83,340 KB |
testcase_20 | AC | 201 ms
84,124 KB |
testcase_21 | AC | 197 ms
83,856 KB |
testcase_22 | AC | 185 ms
77,668 KB |
testcase_23 | AC | 253 ms
78,332 KB |
testcase_24 | AC | 228 ms
78,044 KB |
testcase_25 | AC | 295 ms
85,404 KB |
testcase_26 | AC | 198 ms
83,740 KB |
testcase_27 | AC | 159 ms
83,416 KB |
ソースコード
mod = 998244353 def main(): import sys input = sys.stdin.readline class UnionFind(): def __init__(self, n): self.n = n self.root = [-1] * (n + 1) self.rnk = [0] * (n + 1) def find_root(self, x): while self.root[x] >= 0: x = self.root[x] return x def unite(self, x, y): x = self.find_root(x) y = self.find_root(y) if x == y: return elif self.rnk[x] > self.rnk[y]: self.root[x] += self.root[y] self.root[y] = x else: self.root[y] += self.root[x] self.root[x] = y if self.rnk[x] == self.rnk[y]: self.rnk[y] += 1 def isSameGroup(self, x, y): return self.find_root(x) == self.find_root(y) def size(self, x): return -self.root[self.find_root(x)] N, M = map(int, input().split()) UF = UnionFind(N * 2) for _ in range(M): a, b = map(int, input().split()) UF.unite(a, b + N) UF.unite(a + N, b) ok = 1 for v in range(1, N + 1): if not UF.isSameGroup(v, v+N): ok = 0 break if ok: print("Yes") else: print("No") if __name__ == '__main__': main()