結果

問題 No.2711 Connecting Lights
ユーザー rurunrurun
提出日時 2024-03-31 14:42:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 206 ms / 5,000 ms
コード長 878 bytes
コンパイル時間 2,227 ms
コンパイル使用メモリ 206,636 KB
実行使用メモリ 9,088 KB
最終ジャッジ日時 2024-03-31 14:42:10
合計ジャッジ時間 4,928 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 4 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 4 ms
6,676 KB
testcase_09 AC 120 ms
6,784 KB
testcase_10 AC 80 ms
6,676 KB
testcase_11 AC 143 ms
8,192 KB
testcase_12 AC 33 ms
6,676 KB
testcase_13 AC 38 ms
6,676 KB
testcase_14 AC 5 ms
6,676 KB
testcase_15 AC 21 ms
6,676 KB
testcase_16 AC 4 ms
6,676 KB
testcase_17 AC 5 ms
6,676 KB
testcase_18 AC 7 ms
6,676 KB
testcase_19 AC 113 ms
7,184 KB
testcase_20 AC 41 ms
6,676 KB
testcase_21 AC 4 ms
6,676 KB
testcase_22 AC 2 ms
6,676 KB
testcase_23 AC 3 ms
6,676 KB
testcase_24 AC 71 ms
6,676 KB
testcase_25 AC 93 ms
6,676 KB
testcase_26 AC 206 ms
9,088 KB
testcase_27 AC 178 ms
9,088 KB
testcase_28 AC 203 ms
9,088 KB
testcase_29 AC 170 ms
9,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using lint = long long;
int main() {
  lint n, m, K;
  cin >> n >> m >> K;
  vector dp(m+1, vector<lint>((1<<n), 0));
  const lint MOD = 998244353;
  // i列目まで見て、i列目がjのときの場合数
  
  dp[0][0] = 1;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < (1<<n); j++) {
      for (int k = 0; k < (1<<n); k++) {
        // jとkの組み合わせok?
        int cnt = 0;
        for (int l = 0; l < n; l++) {
          if ((1<<l)&j&k) cnt++;
        }
        if (i == 0 || cnt >= K) {
          // 遷移できる
          dp[i+1][k]+=dp[i][j];
          dp[i+1][k] %= MOD;
        }
      }
    }
  }
  lint ans = 0;
  for (int i = 0; i < (1<<n); i++) {
    ans += dp[m][i];
  }
  cout << ans%MOD << endl;
  return 0;
  for (auto x : dp) {
    for (auto y : x) cout << y << " ";
    cout << endl;
  }
}
0