結果

問題 No.2134 $\sigma$-algebra over Finite Set
ユーザー 👑 chro_96chro_96
提出日時 2022-11-26 11:08:14
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,610 bytes
コンパイル時間 322 ms
コンパイル使用メモリ 30,948 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-07-25 21:22:55
合計ジャッジ時間 2,592 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 1 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 6 ms
4,380 KB
testcase_11 AC 6 ms
4,376 KB
testcase_12 AC 21 ms
4,376 KB
testcase_13 AC 47 ms
4,376 KB
testcase_14 AC 4 ms
4,376 KB
testcase_15 AC 6 ms
4,376 KB
testcase_16 AC 5 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 0 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>

typedef struct arr {
  int n;
  long long *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] = {};
  
  long long work[20000] = {};
  
  res = scanf("%d", &n);
  res = scanf("%d", &m);
  
  for (int i = 0; i < n; i++) {
    inc[i].n = 1+m/60;
    inc[i].a = work+((1+m/60)*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/60] |= (1LL<<((long long)(i%60)));
    }
  }
  
  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