結果
問題 | No.1610 She Loves Me, She Loves Me Not, ... |
ユーザー | tassei903 |
提出日時 | 2021-07-21 21:45:27 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,862 bytes |
コンパイル時間 | 317 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 77,044 KB |
最終ジャッジ日時 | 2024-07-17 17:17:32 |
合計ジャッジ時間 | 3,148 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
54,016 KB |
testcase_01 | AC | 48 ms
61,568 KB |
testcase_02 | AC | 43 ms
54,272 KB |
testcase_03 | AC | 43 ms
54,528 KB |
testcase_04 | AC | 43 ms
54,272 KB |
testcase_05 | WA | - |
testcase_06 | AC | 79 ms
77,044 KB |
testcase_07 | AC | 69 ms
71,808 KB |
testcase_08 | AC | 65 ms
70,016 KB |
testcase_09 | WA | - |
testcase_10 | AC | 68 ms
71,936 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 55 ms
65,288 KB |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | AC | 44 ms
54,784 KB |
testcase_17 | AC | 44 ms
55,040 KB |
testcase_18 | WA | - |
testcase_19 | AC | 43 ms
54,656 KB |
testcase_20 | WA | - |
testcase_21 | AC | 46 ms
54,528 KB |
testcase_22 | WA | - |
testcase_23 | AC | 42 ms
54,528 KB |
testcase_24 | AC | 43 ms
54,016 KB |
testcase_25 | AC | 42 ms
53,760 KB |
testcase_26 | AC | 43 ms
54,256 KB |
testcase_27 | WA | - |
testcase_28 | AC | 43 ms
54,272 KB |
testcase_29 | AC | 43 ms
54,016 KB |
testcase_30 | AC | 43 ms
54,016 KB |
testcase_31 | AC | 42 ms
54,400 KB |
testcase_32 | AC | 43 ms
54,016 KB |
testcase_33 | AC | 43 ms
53,888 KB |
testcase_34 | AC | 42 ms
54,272 KB |
testcase_35 | AC | 43 ms
53,888 KB |
ソースコード
import sys input = lambda :sys.stdin.readline()[:-1] ni = lambda :int(input()) na = lambda :list(map(int,input().split())) sys.setrecursionlimit(10**7) yes = lambda :print("yes");Yes = lambda :print("Yes") no = lambda :print("no");No = lambda :print("No") ####################################################################### from collections import defaultdict 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): group_members = defaultdict(list) for member in range(self.n): group_members[self.find(member)].append(member) return group_members def __str__(self): return '\n'.join(f'{r}: {m}' for r, m in self.all_group_members().items()) n, m = na() uf = UnionFind(n) for i in range(m): a,b = na() a-=1;b-=1; if uf.same(a,b): No() exit() uf.union(a, b) ans = 0 for i in uf.roots(): ans=(ans+uf.size(i)-1)%2 if ans: Yes() else: No()