結果

問題 No.2711 Connecting Lights
ユーザー haihamabossuhaihamabossu
提出日時 2024-03-31 15:14:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 7 ms / 5,000 ms
コード長 947 bytes
コンパイル時間 2,180 ms
コンパイル使用メモリ 204,760 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-31 15:14:14
合計ジャッジ時間 3,265 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
6,676 KB
testcase_05 AC 3 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 5 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 3 ms
6,676 KB
testcase_12 AC 3 ms
6,676 KB
testcase_13 AC 3 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 3 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 3 ms
6,676 KB
testcase_21 AC 2 ms
6,676 KB
testcase_22 AC 2 ms
6,676 KB
testcase_23 AC 2 ms
6,676 KB
testcase_24 AC 3 ms
6,676 KB
testcase_25 AC 5 ms
6,676 KB
testcase_26 AC 7 ms
6,676 KB
testcase_27 AC 3 ms
6,676 KB
testcase_28 AC 6 ms
6,676 KB
testcase_29 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/modint>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using mint = atcoder::modint998244353;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

ll n, m, k;
mint c[20][20];
void solve() {
  cin >> n >> m >> k;
  c[0][0] = 1;
  rep(i, 10) rep(j, i + 1) {
    c[i + 1][j] += c[i][j];
    c[i + 1][j + 1] += c[i][j];
  }
  vector<mint> dp(n + 1, 0);
  rep(i, n + 1) dp[i] = c[n][i];
  for (ll j = 1; j < m; j++) {
    vector<mint> p(n + 1, 0);
    swap(dp, p);
    for (ll pi = k; pi <= n; pi++) {
      for (ll ni = k; ni <= n; ni++) {
        for (ll si = min(pi, ni); si >= k; si--) {
          dp[ni] += p[pi] * c[pi][si] * c[n - pi][ni - si];
        }
      }
    }
  }
  mint ans = 0;
  rep(i, n + 1) ans += dp[i];
  cout << ans.val() << '\n';
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  int T = 1;
  for (int t = 0; t < T; t++) {
    solve();
  }
  return 0;
}
0