結果

問題 No.2152 [Cherry Anniversary 2] 19 Petals of Cherry
ユーザー 👑 chro_96chro_96
提出日時 2022-12-09 01:05:18
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 74 ms / 1,000 ms
コード長 827 bytes
コンパイル時間 1,935 ms
コンパイル使用メモリ 31,232 KB
実行使用メモリ 17,456 KB
最終ジャッジ日時 2024-04-22 18:51:48
合計ジャッジ時間 4,969 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
17,408 KB
testcase_01 AC 64 ms
17,408 KB
testcase_02 AC 49 ms
17,408 KB
testcase_03 AC 71 ms
17,436 KB
testcase_04 AC 74 ms
17,408 KB
testcase_05 AC 71 ms
17,408 KB
testcase_06 AC 68 ms
17,408 KB
testcase_07 AC 72 ms
17,408 KB
testcase_08 AC 69 ms
17,408 KB
testcase_09 AC 69 ms
17,280 KB
testcase_10 AC 69 ms
17,280 KB
testcase_11 AC 71 ms
17,408 KB
testcase_12 AC 68 ms
17,408 KB
testcase_13 AC 67 ms
17,408 KB
testcase_14 AC 69 ms
17,408 KB
testcase_15 AC 70 ms
17,408 KB
testcase_16 AC 71 ms
17,336 KB
testcase_17 AC 73 ms
17,364 KB
testcase_18 AC 72 ms
17,288 KB
testcase_19 AC 70 ms
17,328 KB
testcase_20 AC 66 ms
17,408 KB
testcase_21 AC 69 ms
17,372 KB
testcase_22 AC 68 ms
17,408 KB
testcase_23 AC 74 ms
17,380 KB
testcase_24 AC 73 ms
17,440 KB
testcase_25 AC 74 ms
17,408 KB
testcase_26 AC 70 ms
17,280 KB
testcase_27 AC 64 ms
17,408 KB
testcase_28 AC 56 ms
17,408 KB
testcase_29 AC 58 ms
17,408 KB
testcase_30 AC 59 ms
17,408 KB
testcase_31 AC 58 ms
17,320 KB
testcase_32 AC 60 ms
17,408 KB
testcase_33 AC 61 ms
17,408 KB
testcase_34 AC 61 ms
17,408 KB
testcase_35 AC 64 ms
17,408 KB
testcase_36 AC 69 ms
17,280 KB
testcase_37 AC 68 ms
17,408 KB
testcase_38 AC 68 ms
17,408 KB
testcase_39 AC 66 ms
17,456 KB
testcase_40 AC 67 ms
17,408 KB
testcase_41 AC 69 ms
17,280 KB
testcase_42 AC 70 ms
17,384 KB
testcase_43 AC 67 ms
17,408 KB
testcase_44 AC 66 ms
17,408 KB
testcase_45 AC 55 ms
17,420 KB
testcase_46 AC 61 ms
17,408 KB
testcase_47 AC 51 ms
17,280 KB
testcase_48 AC 70 ms
17,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main () {
  int l = 0;
  int a = 0;
  
  int res = 0;
  
  long long dp[1000000][2] = {};
  
  int a_set[19] = {};
  
  for (int i = 0; i < 19; i++) {
    res = scanf("%d", &l);
    for (int j = 0; j < l; j++) {
      res = scanf("%d", &a);
      a_set[i] |= (1<<(a-1));
    }
  }
  
  dp[0][0] = 1LL;
  for (int i = 0; i < (1<<19)-1; i++) {
    int cnt = 0;
    int gt_num = 0;
    for (int j = 0; j < 19; j++) {
      if ((i&(1<<j)) > 0) {
        cnt++;
      }
    }
    for (int j = 18; j >= 0; j--) {
      if ((i&(1<<j)) > 0) {
        gt_num++;
      } else if ((a_set[cnt]&(1<<j)) > 0) {
        int idx = (i|(1<<j));
        dp[idx][0] += dp[i][gt_num%2];
        dp[idx][1] += dp[i][1-gt_num%2];
      }
    }
  }
  
  printf("%lld %lld\n", dp[(1<<19)-1][0], dp[(1<<19)-1][1]);
  return 0;
}
0