結果
問題 | No.2711 Connecting Lights |
ユーザー | shobonvip |
提出日時 | 2024-04-01 01:47:50 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 42 ms / 5,000 ms |
コード長 | 1,933 bytes |
コンパイル時間 | 4,658 ms |
コンパイル使用メモリ | 266,840 KB |
実行使用メモリ | 12,212 KB |
最終ジャッジ日時 | 2024-04-01 01:47:57 |
合計ジャッジ時間 | 6,822 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 14 ms
11,444 KB |
testcase_01 | AC | 14 ms
11,444 KB |
testcase_02 | AC | 14 ms
11,444 KB |
testcase_03 | AC | 14 ms
11,444 KB |
testcase_04 | AC | 14 ms
11,444 KB |
testcase_05 | AC | 16 ms
11,844 KB |
testcase_06 | AC | 14 ms
11,444 KB |
testcase_07 | AC | 14 ms
11,572 KB |
testcase_08 | AC | 15 ms
11,572 KB |
testcase_09 | AC | 30 ms
11,828 KB |
testcase_10 | AC | 16 ms
11,744 KB |
testcase_11 | AC | 19 ms
12,084 KB |
testcase_12 | AC | 21 ms
11,956 KB |
testcase_13 | AC | 19 ms
12,212 KB |
testcase_14 | AC | 15 ms
11,700 KB |
testcase_15 | AC | 21 ms
11,752 KB |
testcase_16 | AC | 16 ms
11,860 KB |
testcase_17 | AC | 18 ms
11,956 KB |
testcase_18 | AC | 16 ms
11,760 KB |
testcase_19 | AC | 17 ms
11,868 KB |
testcase_20 | AC | 23 ms
12,212 KB |
testcase_21 | AC | 17 ms
11,956 KB |
testcase_22 | AC | 15 ms
11,572 KB |
testcase_23 | AC | 16 ms
12,212 KB |
testcase_24 | AC | 20 ms
11,688 KB |
testcase_25 | AC | 26 ms
11,828 KB |
testcase_26 | AC | 42 ms
12,212 KB |
testcase_27 | AC | 23 ms
12,212 KB |
testcase_28 | AC | 42 ms
12,212 KB |
testcase_29 | AC | 18 ms
12,212 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; //* ATCODER #include<atcoder/all> using namespace atcoder; typedef modint998244353 mint; //*/ /* BOOST MULTIPRECISION #include<boost/multiprecision/cpp_int.hpp> using namespace boost::multiprecision; //*/ typedef long long ll; #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--) template <typename T> bool chmin(T &a, const T &b) { if (a <= b) return false; a = b; return true; } template <typename T> bool chmax(T &a, const T &b) { if (a >= b) return false; a = b; return true; } template <typename T> T max(vector<T> &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]); return ret; } template <typename T> T min(vector<T> &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]); return ret; } template <typename T> T sum(vector<T> &a){ T ret = 0; for (int i=0; i<(int)a.size(); i++) ret += a[i]; return ret; } //defmodfact const int COMinitMAX = 998244; mint fact[COMinitMAX+1], factinv[COMinitMAX+1]; void modfact(){ fact[0] = 1; for (int i=1; i<=COMinitMAX; i++){ fact[i] = fact[i-1] * i; } factinv[COMinitMAX] = fact[COMinitMAX].inv(); for (int i=COMinitMAX-1; i>=0; i--){ factinv[i] = factinv[i+1] * (i+1); } } mint cmb(int a, int b){ if (a<b || b<0) return mint(0); return fact[a]*factinv[b]*factinv[a-b]; } //-------- int main(){ modfact(); int n, m, k; cin >> n >> m >> k; mint ans = 0; vector<vector<mint>> dp(m, vector<mint>(n+1)); rep(i,0,n+1){ dp[0][i] = cmb(n, i); } rep(i,0,m-1){ rep(x,0,n+1){ rep(y,0,n+1){ rep(l,k,n+1){ if (x<k || y<k) continue; // x - l - y // cmb(x, l) * cmb(n - x, y - l) dp[i+1][y] += dp[i][x] * cmb(x, l) * cmb(n-x, y-l); } } } } rep(i,0,n+1){ ans += dp[m-1][i]; } cout << ans.val() << '\n'; }