結果

問題 No.2711 Connecting Lights
ユーザー takumi152takumi152
提出日時 2024-03-31 15:09:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 151 ms / 5,000 ms
コード長 1,561 bytes
コンパイル時間 1,154 ms
コンパイル使用メモリ 106,360 KB
実行使用メモリ 9,088 KB
最終ジャッジ日時 2024-03-31 15:09:54
合計ジャッジ時間 2,992 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 5 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 3 ms
6,676 KB
testcase_09 AC 89 ms
6,784 KB
testcase_10 AC 58 ms
6,676 KB
testcase_11 AC 99 ms
8,192 KB
testcase_12 AC 27 ms
6,676 KB
testcase_13 AC 29 ms
6,676 KB
testcase_14 AC 5 ms
6,676 KB
testcase_15 AC 19 ms
6,676 KB
testcase_16 AC 5 ms
6,676 KB
testcase_17 AC 5 ms
6,676 KB
testcase_18 AC 6 ms
6,676 KB
testcase_19 AC 85 ms
7,168 KB
testcase_20 AC 32 ms
6,676 KB
testcase_21 AC 4 ms
6,676 KB
testcase_22 AC 3 ms
6,676 KB
testcase_23 AC 3 ms
6,676 KB
testcase_24 AC 51 ms
6,676 KB
testcase_25 AC 68 ms
6,676 KB
testcase_26 AC 150 ms
9,088 KB
testcase_27 AC 121 ms
9,088 KB
testcase_28 AC 151 ms
9,088 KB
testcase_29 AC 127 ms
9,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 998244353;

ll modpow(ll a, ll b, ll m = mod) {
  ll r = 1;
  while (b > 0) {
    if (b & 1) r = (r * a) % m;
    a = (a * a) % m;
    b >>= 1;
  }
  return r;
}

ll modinv(ll x, ll m = mod) {
  ll b = m;
  ll u = 1;
  ll v = 0;
  ll tmp;
  while (b) {
    ll t = x / b;
    x -= t * b;
    tmp = x;
    x = b;
    b = tmp;
    u -= t * v;
    tmp = u;
    u = v;
    v = tmp;
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

ll modcomb(ll n, ll r, ll m = mod) {
  if (r < 0 || r > n) return 0;
  r = min(r, n - r);
  ll num = 1;
  ll denom = 1;
  for (ll i = 0; i < r; i++) {
    num = (num * (n - i)) % m;
    denom = (denom * (i + 1)) % m;
  }
  return (num * modinv(denom, m)) % m;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll n, m, k;
  cin >> n >> m >> k;

  vector<vector<ll>> dp(m, vector<ll>(1 << n));
  for (int j = 0; j < (1 << n); j++) dp[0][j] = 1;
  for (int i = 1; i < m; i++) {
    for (int j = 0; j < (1 << n); j++) {
      for (int l = 0; l < (1 << n); l++) {
        if (__builtin_popcount(j & l) >= k) {
          dp[i][l] = (dp[i][l] + dp[i-1][j]) % mod;
        }
      }
    }
  }

  ll ans = 0;
  for (int j = 0; j < (1 << n); j++) ans = (ans + dp[m-1][j]) % mod;

  cout << ans << endl;

  return 0;
}
0