結果
| 問題 | 
                            No.2134 $\sigma$-algebra over Finite Set
                             | 
                    
| コンテスト | |
| ユーザー | 
                             chro_96
                         | 
                    
| 提出日時 | 2022-11-25 23:41:17 | 
| 言語 | C  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 111 ms / 2,000 ms | 
| コード長 | 1,559 bytes | 
| コンパイル時間 | 334 ms | 
| コンパイル使用メモリ | 31,104 KB | 
| 実行使用メモリ | 5,760 KB | 
| 最終ジャッジ日時 | 2024-10-07 07:42:40 | 
| 合計ジャッジ時間 | 1,510 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 17 | 
ソースコード
#include <stdio.h>
#include <stdlib.h>
typedef struct arr {
  int n;
  int *a;
} arr;
int cmp_arr (const void *ap, const void *bp) {
  arr a = *(arr *)ap;
  arr b = *(arr *)bp;
  int idx = 0;
  
  while (idx < a.n && idx < b.n) {
    if (a.a[idx] < b.a[idx]) {
      return -1;
    }
    if (a.a[idx] > b.a[idx]) {
      return 1;
    }
    idx++;
  }
  
  if (a.n < b.n) {
    return -1;
  }
  
  if (a.n > b.n) {
    return 1;
  }
  
  return 0;
}
long long power_mod (long long a, long  long b, long long mod_num) {
  long long ans = 1LL;
  
  if (b > 0LL) {
    ans = power_mod(a, b/2LL, mod_num);
    ans = (ans * ans) % mod_num;
    if (b%2LL == 1LL) {
      ans = (ans *a) % mod_num;
    }
  }
  
  return ans;
}
int main () {
  int n = 0;
  int m = 0;
  int l = 0;
  int a = 0;
  
  int res = 0;
  
  int ans = 0;
  long long mod_num = 998244353LL;
  
  arr inc[1000] = {};
  
  int work[1000000] = {};
  
  res = scanf("%d", &n);
  res = scanf("%d", &m);
  
  for (int i = 0; i < n; i++) {
    inc[i].n = m;
    inc[i].a = work+(m*i);
  }
  
  for (int i = 0; i < m; i++) {
    res = scanf("%d", &l);
    for (int j = 0; j < l; j++) {
      res = scanf("%d", &a);
      a--;
      inc[a].a[i] = 1;
    }
  }
  
  qsort(inc, n, sizeof(arr), cmp_arr);
  
  ans = n;
  for (int i = 1; i < n; i++) {
    int is_ok = 1;
    for (int j = 0; j < m; j++) {
      if (inc[i-1].a[j] != inc[i].a[j]) {
        is_ok = 0;
      }
    }
    if (is_ok > 0) {
      ans--;
    }
  }
  
  printf("%lld\n", power_mod(2LL, (long long)ans, mod_num));
  return 0;
}
            
            
            
        
            
chro_96