結果
問題 | No.2134 $\sigma$-algebra over Finite Set |
ユーザー | だれ |
提出日時 | 2022-11-06 20:24:41 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,087 bytes |
コンパイル時間 | 155 ms |
コンパイル使用メモリ | 81,772 KB |
実行使用メモリ | 84,604 KB |
最終ジャッジ日時 | 2023-10-24 16:20:11 |
合計ジャッジ時間 | 4,082 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | AC | 452 ms
84,600 KB |
testcase_02 | AC | 444 ms
84,604 KB |
testcase_03 | AC | 35 ms
53,616 KB |
testcase_04 | AC | 114 ms
76,380 KB |
testcase_05 | AC | 35 ms
53,616 KB |
testcase_06 | AC | 125 ms
76,492 KB |
testcase_07 | AC | 134 ms
76,512 KB |
testcase_08 | AC | 66 ms
62,304 KB |
testcase_09 | AC | 64 ms
62,304 KB |
testcase_10 | AC | 253 ms
79,036 KB |
testcase_11 | AC | 252 ms
78,980 KB |
testcase_12 | AC | 285 ms
79,572 KB |
testcase_13 | AC | 285 ms
79,872 KB |
testcase_14 | AC | 105 ms
76,544 KB |
testcase_15 | RE | - |
testcase_16 | AC | 94 ms
76,488 KB |
testcase_17 | AC | 36 ms
53,616 KB |
testcase_18 | AC | 35 ms
53,616 KB |
ソースコード
class UnionFind: def __init__(self, _n): self.v = [-1] * _n self.n = _n def find(self, x): if self.v[x] < 0: return x self.v[x] = self.find(self.v[x]) return self.v[x] def merge(self, a, b): a = self.find(a) b = self.find(b) if a == b: return if self.v[a] > self.v[b]: a, b = b, a self.v[a] += self.v[b] self.v[b] = a def size(self): res = 0 for i in range(self.n): if self.v[i] < 0: res += 1 return res n, m = map(int, input().split()) B = [(2 ** n - 1)] * n A, A_c = [0] * n, [0] * n for i in range(m): l, *a = map(int, input().split()) for j in range(l): A[i] |= 1 << (a[j] - 1) A_c[i] = ~A[i] for j in range(n): if (A[i] >> j) & 1: B[j] &= A[i] else: B[j] &= A_c[i] uf = UnionFind(n) for i in range(n): for j in range(n): if B[i] == B[j]: uf.merge(i, j) print(pow(2, uf.size(), 998244353))