結果
| 問題 |
No.2711 Connecting Lights
|
| コンテスト | |
| ユーザー |
うえこ
|
| 提出日時 | 2024-03-31 14:30:29 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 20 ms / 5,000 ms |
| コード長 | 1,244 bytes |
| コンパイル時間 | 3,109 ms |
| コンパイル使用メモリ | 251,640 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-09-30 19:37:25 |
| 合計ジャッジ時間 | 3,448 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#include <bits/stdc++.h>
using ll=long long;
const long long INF=1LL<<60;
ll comb(ll a,ll b){
ll val=1;
for(int i=0;i<b;++i){
val*=a;val/=(i+1);
--a;
}
return val;
}
int main(){
ll n,m,k;
std::cin >> n >> m >> k;
std::vector<std::vector<ll>>dp(m,std::vector<ll>(n+1));
ll mod=998244353;
for(int bit=0;bit<(1LL<<n);++bit){
int cnt=0;
for(int i=0;i<n;++i){
if(bit&(1LL<<i))++cnt;
}
dp[0][cnt]++;
}
for(int i=0;i<m-1;++i){
for(int j=0;j<=n;++j){
for(int common=k;common<=j;++common){//jの中から共通のcommonこを選ぶのでchoose j, common
ll add=comb(j,common);add%=mod;
add*=dp[i][j];add%=mod;
int other=n-j;
for(int bit=0;bit<(1LL<<other);++bit){
int cnt=0;
for(int b=0;b<n;++b){
if(bit&(1LL<<b))++cnt;
}
int tot=cnt+common;
dp[i+1][tot]+=add;dp[i+1][tot]%=mod;
}
}
}
}
ll ans=0;
for(int i=0;i<=n;++i){
ans+=dp.back()[i];ans%=mod;
}
std::cout << ans << '\n';
}
うえこ