結果

問題 No.2134 $\sigma$-algebra over Finite Set
ユーザー flygonflygon
提出日時 2022-11-25 23:58:01
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,038 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 82,708 KB
実行使用メモリ 68,748 KB
最終ジャッジ日時 2024-04-10 04:53:39
合計ジャッジ時間 2,433 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 WA -
testcase_04 RE -
testcase_05 WA -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 45 ms
55,512 KB
testcase_09 AC 43 ms
55,688 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 AC 42 ms
56,432 KB
testcase_18 AC 43 ms
55,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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