結果

問題 No.2134 $\sigma$-algebra over Finite Set
コンテスト
ユーザー flygon
提出日時 2022-11-25 23:58:01
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
RE  
実行時間 -
コード長 1,038 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 470 ms
コンパイル使用メモリ 85,120 KB
実行使用メモリ 68,608 KB
最終ジャッジ日時 2026-04-18 16:18:04
合計ジャッジ時間 2,729 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 2 WA * 2 RE * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline
import pypyjit
pypyjit.set_param('max_unroll_recursion=-1')
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(a[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 not flg:
    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, mod)
  ans %= mod

print(ans)



0