結果

問題 No.1710 Minimum OR is X
ユーザー chocoruskchocorusk
提出日時 2021-10-15 22:03:22
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 1,882 bytes
コンパイル時間 4,059 ms
コンパイル使用メモリ 190,832 KB
実行使用メモリ 19,548 KB
最終ジャッジ日時 2023-10-17 20:19:06
合計ジャッジ時間 5,275 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
19,516 KB
testcase_01 AC 7 ms
19,516 KB
testcase_02 AC 11 ms
19,520 KB
testcase_03 AC 7 ms
19,516 KB
testcase_04 AC 7 ms
19,516 KB
testcase_05 AC 7 ms
19,516 KB
testcase_06 AC 6 ms
19,516 KB
testcase_07 AC 6 ms
19,516 KB
testcase_08 AC 18 ms
19,544 KB
testcase_09 AC 19 ms
19,540 KB
testcase_10 AC 23 ms
19,544 KB
testcase_11 AC 15 ms
19,544 KB
testcase_12 AC 34 ms
19,540 KB
testcase_13 AC 23 ms
19,548 KB
testcase_14 AC 28 ms
19,544 KB
testcase_15 AC 11 ms
19,540 KB
testcase_16 AC 33 ms
19,544 KB
testcase_17 AC 9 ms
19,532 KB
testcase_18 AC 78 ms
19,548 KB
testcase_19 AC 43 ms
19,548 KB
testcase_20 AC 10 ms
19,548 KB
testcase_21 AC 89 ms
19,548 KB
testcase_22 AC 110 ms
19,548 KB
testcase_23 AC 7 ms
19,528 KB
testcase_24 AC 6 ms
19,520 KB
testcase_25 AC 7 ms
19,528 KB
testcase_26 AC 7 ms
19,544 KB
testcase_27 AC 6 ms
19,528 KB
testcase_28 AC 15 ms
19,548 KB
testcase_29 AC 7 ms
19,528 KB
testcase_30 AC 6 ms
19,516 KB
testcase_31 AC 7 ms
19,524 KB
testcase_32 AC 15 ms
19,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
using mint=modint998244353;
mint f[2000010], invf[2000010];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i;
    invf[n]=f[n].inv();
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1);
}
mint comb(int x, int y){
    if(!(0<=y && y<=x)) return 0;
    return f[x]*invf[y]*invf[x-y];
}
int main()
{
    int n, m, k;
    cin>>n>>m>>k;
    fac(n+m);
    string x; cin>>x;
    bool ok[202][202]={};
    mint dp[202][202];
    auto solve=[&](auto solve, int i, int c)->mint{
        if(ok[i][c])return dp[i][c];
        ok[i][c]=1;
        if(i==m-1){
            mint s=0;
            for(int j=0; j<k && j<=c; j++){
                s+=comb(c, j);
            }
            if(x[i]=='0'){
                return dp[i][c]=mint(2).pow(c)-s;
            }else{
                return dp[i][c]=s;
            }
        }
        mint res=0;
        if(x[i]=='0'){
            for(int j=k; j<=c; j++){
                res+=solve(solve, i+1, j)*comb(c, j)*(mint(2).pow((m-1-i)*(c-j)));
            }
        }else{
            mint s=0;
            for(int j=0; j<k && j<=c; j++){
                s+=comb(c, j);
            }
            res+=s*solve(solve, i+1, c);
        }
        return dp[i][c]=res;
    };
    cout<<solve(solve, 0, n).val()<<endl;
    return 0;
}
0