結果

問題 No.2711 Connecting Lights
ユーザー tnakao0123tnakao0123
提出日時 2024-04-30 10:29:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 39 ms / 5,000 ms
コード長 1,053 bytes
コンパイル時間 416 ms
コンパイル使用メモリ 45,184 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-30 10:29:23
合計ジャッジ時間 2,189 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 4 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 3 ms
6,940 KB
testcase_09 AC 23 ms
6,940 KB
testcase_10 AC 4 ms
6,944 KB
testcase_11 AC 7 ms
6,944 KB
testcase_12 AC 8 ms
6,944 KB
testcase_13 AC 6 ms
6,940 KB
testcase_14 AC 3 ms
6,940 KB
testcase_15 AC 7 ms
6,940 KB
testcase_16 AC 5 ms
6,944 KB
testcase_17 AC 4 ms
6,944 KB
testcase_18 AC 4 ms
6,940 KB
testcase_19 AC 4 ms
6,944 KB
testcase_20 AC 9 ms
6,944 KB
testcase_21 AC 4 ms
6,944 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 6 ms
6,944 KB
testcase_24 AC 11 ms
6,940 KB
testcase_25 AC 18 ms
6,944 KB
testcase_26 AC 39 ms
6,940 KB
testcase_27 AC 17 ms
6,944 KB
testcase_28 AC 39 ms
6,940 KB
testcase_29 AC 6 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2711.cc:  No.2711 Connecting Lights - yukicoder
 */

#include<cstdio>
#include<algorithm>
 
using namespace std;

/* constant */

const int MAX_N = 5;
const int NBITS = 1 << MAX_N;
const int MAX_M = 20000;
const int MOD = 998244353;

/* typedef */

/* global variables */

int bnums[NBITS], dp[MAX_M][NBITS];

/* subroutines */

inline void addmod(int &a, int b) { a = (a + b) % MOD; }

/* main */

int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);

  int nbits = 1 << n;
  for (int bits = 1, msb = 1; bits < nbits; bits++) {
    if ((msb << 1) <= bits) msb <<= 1;
    bnums[bits] = bnums[bits ^ msb] + 1;
  }

  fill(dp[0], dp[0] + nbits, 1);
  for (int i = 0; i + 1 < m; i++)
    for (int bits0 = 0; bits0 < nbits; bits0++)
      if ((int)dp[i][bits0])
	for (int bits1 = 0; bits1 < nbits; bits1++)
	  if (bnums[bits0 & bits1] >= k)
	    addmod(dp[i + 1][bits1], dp[i][bits0]);

  int sum = 0;
  for (int bits = 0; bits < nbits; bits++)
    addmod(sum, dp[m - 1][bits]);

  printf("%d\n", sum);
  
  return 0;
}
0