結果
問題 | No.2711 Connecting Lights |
ユーザー | ynishi2015 |
提出日時 | 2024-03-31 14:35:29 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 48 ms / 5,000 ms |
コード長 | 799 bytes |
コンパイル時間 | 862 ms |
コンパイル使用メモリ | 90,384 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-09-30 19:43:22 |
合計ジャッジ時間 | 2,172 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <cmath> using namespace std; int popcount(int x){ int c = 0; while(x){ x &= x - 1; ++c; } return c; } int main() { int N, M, K; cin >> N >> M >> K; vector<int> dp(1 << N, 1); int NN = 1 << N; int mod = 998244353; for(int i = 0; i < M-1; i++){ vector<int> dpn(1 << N, 0); for(int b = 0; b < NN; b++){ for(int c = 0; c < NN; c++){ if(popcount(c & b) >= K){ dpn[c] += dp[b]; } dpn[c] %= mod; } } dp = dpn; } int sum = 0; for(int i = 0; i < NN; i++){ sum += dp[i]; sum %= mod; } cout << sum << endl; return 0; }