結果

問題 No.2134 $\sigma$-algebra over Finite Set
ユーザー flygon
提出日時 2022-11-26 00:02:46
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 950 bytes
コンパイル時間 343 ms
コンパイル使用メモリ 82,400 KB
実行使用メモリ 102,324 KB
最終ジャッジ日時 2024-10-02 06:26:21
合計ジャッジ時間 3,233 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 4 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from collections import defaultdict, deque, Counter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
from math import gcd

mod = 998244353
n,m = map(int,input().split())
s = set()
a = []
l = []
for i in range(m):
  aa = list(map(int,input().split()))
  l.append(aa[0])
  a.append(set(aa[1:]))

p = [-1]*(m+1)
def find(x):
  if p[x] < 0:
    return x
  else:
    p[x] = find(p[x])
    return p[x]
def union(x,y):
  x = find(x)
  y = find(y)
  if x == y:
    return
  if p[x] > p[y]:
    x,y = y,x
  p[x] += p[y]
  p[y] = x
un = []
for i in range(1,n+1):
  rep = -1
  flg = 0
  for j in range(m):
    if i in a[j] and rep == -1:
      rep = j
      flg = 1
    else:
      union(j,rep)
  if flg == 0:
    un.append(i)

d = defaultdict(int)
for i in range(1,m+1):
  d[find(i)] += 1

ans = pow(2, (un != []))
for v in d.values():
  ans *= pow(2, v+1, mod)
  ans %= mod

print(ans)



0