結果

問題 No.2711 Connecting Lights
ユーザー ococonomy1ococonomy1
提出日時 2024-03-31 14:01:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 47 ms / 5,000 ms
コード長 2,426 bytes
コンパイル時間 1,206 ms
コンパイル使用メモリ 118,724 KB
実行使用メモリ 9,088 KB
最終ジャッジ日時 2024-03-31 14:01:48
合計ジャッジ時間 2,389 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 3 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 28 ms
6,784 KB
testcase_10 AC 22 ms
6,676 KB
testcase_11 AC 39 ms
8,192 KB
testcase_12 AC 12 ms
6,676 KB
testcase_13 AC 14 ms
6,676 KB
testcase_14 AC 3 ms
6,676 KB
testcase_15 AC 8 ms
6,676 KB
testcase_16 AC 3 ms
6,676 KB
testcase_17 AC 4 ms
6,676 KB
testcase_18 AC 4 ms
6,676 KB
testcase_19 AC 31 ms
7,168 KB
testcase_20 AC 15 ms
6,676 KB
testcase_21 AC 3 ms
6,676 KB
testcase_22 AC 2 ms
6,676 KB
testcase_23 AC 3 ms
6,676 KB
testcase_24 AC 18 ms
6,676 KB
testcase_25 AC 21 ms
6,676 KB
testcase_26 AC 46 ms
9,088 KB
testcase_27 AC 47 ms
9,088 KB
testcase_28 AC 47 ms
9,088 KB
testcase_29 AC 46 ms
9,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pli = pair<ll,int>;
#define TEST cerr << "TEST" << endl
#define AMARI 998244353
//#define AMARI 1000000007
#define el '\n'
#define El '\n'

#define MULTI_TEST_CASE false
void solve(void){
    //問題を見たらまず「この問題設定から言えること」をいっぱい言う
    //一個回答に繋がりそうな解法が見えても、実装や細かい詰めに時間がかかりそうなら別の方針を考えてみる
    //添え字回りで面倒になりそうなときは楽になる言い換えを実装の前にじっくり考える
    //ある程度考察しても全然取っ掛かりが見えないときは実験をしてみる
    //よりシンプルな問題に言い換えられたら、言い換えた先の問題を自然言語ではっきりと書く
    int h,w;
    int k;
    cin >> h >> w >> k;
    vector<vector<ll>> dp(w,vector<ll>(1 << h,0));
    //S -> T が許されるかどうか 許されるなら1
    vector<vector<int>> sexni(1 << h,vector<int>(1 << h,0));
    for(int i = 0; i < (1 << h); i++){
        for(int j = 0; j < (1 << h); j++){
            int cnt = 0;
            for(int l = 0; l < h; l++){
                if((i & (1 << l)) && (j & (1 << l)))cnt++;
            }
            if(cnt >= k)sexni[i][j] = 1;
        }
    }
    for(int i = 0; i < (1 << h); i++)dp[0][i] = 1;
    for(int j = 0; j < w - 1; j++){
        for(int S = 0; S < (1 << h); S++){
            for(int T = 0; T < (1 << h); T++){
                dp[j + 1][T] += dp[j][S] * sexni[S][T];
                dp[j + 1][T] %= AMARI;
            }
        }
    }
    ll ans = 0;
    for(int i = 0; i < (1 << h); i++){
        ans += dp[w - 1][i];
        ans %= AMARI;
    }
    cout << ans << el;
    return;
}

void calc(void){
    return;
}

signed main(void){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    calc();
    int t = 1;
    if(MULTI_TEST_CASE)cin >> t;
    while(t--){
        solve();
    }
    return 0;
}
0