結果

問題 No.2134 $\sigma$-algebra over Finite Set
ユーザー 👑 chro_96chro_96
提出日時 2022-11-25 23:37:07
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,562 bytes
コンパイル時間 302 ms
コンパイル使用メモリ 32,512 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-10 04:37:48
合計ジャッジ時間 1,681 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,816 KB
testcase_01 AC 103 ms
6,940 KB
testcase_02 AC 105 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 3 ms
6,940 KB
testcase_10 AC 9 ms
6,944 KB
testcase_11 AC 8 ms
6,940 KB
testcase_12 AC 27 ms
6,940 KB
testcase_13 AC 53 ms
6,944 KB
testcase_14 AC 6 ms
6,944 KB
testcase_15 AC 8 ms
6,940 KB
testcase_16 AC 8 ms
6,940 KB
testcase_17 AC 3 ms
6,944 KB
testcase_18 AC 3 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
    }
    return 0;
  }
  
  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 = n;
    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;
}
0