結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 5 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 1 ms
6,676 KB
testcase_06 AC 3 ms
6,676 KB
testcase_07 AC 1 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 13 ms
6,676 KB
testcase_10 AC 13 ms
6,676 KB
testcase_11 AC 14 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 13 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 12 ms
6,676 KB
testcase_25 AC 13 ms
6,676 KB
testcase_26 AC 14 ms
6,676 KB
testcase_27 AC 14 ms
6,676 KB
testcase_28 AC 14 ms
6,676 KB
testcase_29 AC 14 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

long long mod = 998244353;
//入力が必ずmod未満の時に使う.
struct mint{
    long long v = 0;
    mint(){} mint(int a){v = a;} mint(long long a){v = a;} mint(unsigned long long a){v = a;}
    long long val(){return v;}
    void modu(){v %= mod;}
 
    mint repeat2mint(long long a,long long b){
        mint ret = 1,p = a;
        while(b){if(b&1) ret *= p; p *= p; b >>= 1;}
        return ret;
    };
 
    mint operator-(){return mint(0)-mint(v);}
    mint operator+(mint b){return (v+b.v)%mod;}
    mint operator-(mint b){return (v-b.v+mod)%mod;}
    mint operator*(mint b){return v*b.v%mod;}
    mint operator/(mint b){
        if(b.v == 0) assert(false);
        return v*(repeat2mint(b.v,mod-2)).v%mod;
    }
 
    void operator+=(mint b){v = (v+b.v)%mod;}
    void operator-=(mint b){v = (v-b.v+mod)%mod;}
    void operator*=(mint b){v = v*b.v%mod;}
    void operator/=(mint b){
    if(b.v == 0) assert(false);
        v = v*repeat2mint(b.v,mod-2).v%mod;
    }
 
    void operator++(int){v = (v+1)%mod; return;}
    void operator--(int){v = (v-1+mod)%mod; return;}
    bool operator==(mint b){return v == b.v;}
    bool operator!=(mint b){return v != b.v;}
    bool operator>(mint b) {return v >  b.v;}
    bool operator>=(mint b){return v >= b.v;}
    bool operator<(mint b) {return v <  b.v;}
    bool operator<=(mint b){return v <= b.v;}
 
    mint pow(long long x){return repeat2mint(v,x);}
    mint inv(){return mint(1)/v;}
};			

vector<vector<mint>> multima(vector<vector<mint>> &A,vector<vector<mint>> &B){
    int siza = A.size(),sizb = B.at(0).size();
    vector<vector<mint>> ret(siza,vector<mint>(sizb));
    for(int i=0; i<siza; i++) for(int k=0; k<sizb; k++){
        for(int l=0; l<A.at(i).size(); l++){
            ret.at(i).at(k) += A.at(i).at(l)*B.at(l).at(k);
            //ret.at(i).at(k) %= mod;
        }
    }
    return ret;
    //計算できる行列のみ.
}

int main() {
    int N,M,K; cin >> N >> M >> K;

    int n2 = 1<<N;
    vector<vector<mint>> move(n2,vector<mint>(n2));
    for(int i=0; i<n2; i++) for(int k=0; k<n2; k++){
        int ok = 0;
        for(int l=0; l<N; l++) if(i&(1<<l) && k&(1<<l)) ok++;
        if(ok >= K) move.at(k).at(i) = 1;
    }

    vector<vector<mint>> A(n2,{1});
    M--;
    while(M){
        if(M&1) A = multima(move,A);
        move = multima(move,move); M >>= 1;
    }
    mint answer = 0;
    for(auto a : A) for(auto b : a) answer += b;
    cout << answer.v << endl;
}
0