結果

問題 No.1710 Minimum OR is X
ユーザー chineristACchineristAC
提出日時 2021-05-25 20:44:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 541 ms / 2,000 ms
コード長 1,415 bytes
コンパイル時間 236 ms
コンパイル使用メモリ 81,632 KB
実行使用メモリ 85,376 KB
最終ジャッジ日時 2023-10-17 19:43:10
合計ジャッジ時間 9,275 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
70,596 KB
testcase_01 AC 70 ms
70,596 KB
testcase_02 AC 233 ms
84,672 KB
testcase_03 AC 72 ms
70,596 KB
testcase_04 AC 71 ms
70,596 KB
testcase_05 AC 71 ms
70,596 KB
testcase_06 AC 70 ms
70,596 KB
testcase_07 AC 71 ms
70,596 KB
testcase_08 AC 297 ms
84,720 KB
testcase_09 AC 268 ms
84,780 KB
testcase_10 AC 408 ms
84,828 KB
testcase_11 AC 329 ms
84,728 KB
testcase_12 AC 320 ms
84,896 KB
testcase_13 AC 294 ms
84,724 KB
testcase_14 AC 302 ms
84,876 KB
testcase_15 AC 244 ms
84,832 KB
testcase_16 AC 296 ms
84,800 KB
testcase_17 AC 252 ms
84,496 KB
testcase_18 AC 473 ms
84,936 KB
testcase_19 AC 430 ms
85,152 KB
testcase_20 AC 421 ms
84,544 KB
testcase_21 AC 530 ms
85,376 KB
testcase_22 AC 541 ms
85,028 KB
testcase_23 AC 71 ms
70,596 KB
testcase_24 AC 71 ms
70,596 KB
testcase_25 AC 211 ms
83,492 KB
testcase_26 AC 77 ms
73,020 KB
testcase_27 AC 81 ms
75,260 KB
testcase_28 AC 163 ms
84,284 KB
testcase_29 AC 127 ms
83,304 KB
testcase_30 AC 74 ms
70,972 KB
testcase_31 AC 79 ms
75,260 KB
testcase_32 AC 161 ms
84,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 998244353
N = 2*10**5
g1 = [1]*(N+1)
g2 = [1]*(N+1)
inverse = [1]*(N+1)

for i in range( 2, N + 1 ):
    g1[i]=( ( g1[i-1] * i ) % mod )
    inverse[i]=( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2[i]=( (g2[i-1] * inverse[i]) % mod )
inverse[0]=0

pow_2 = [1 for i in range(N)]
for i in range(1,N):
    pow_2[i] = 2 * pow_2[i-1] % mod


import sys,random,bisect
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations
from math import gcd,log

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

N,M,K = mi()
X = input()
dp = [[0 for j in range(N+1)] for bit in range(M+1)]
dp[M][N] = 1
for bit in range(M-1,-1,-1):
    if X[M-1-bit]=="0":
        #bit目が立っているのアがrest-K個以下
        for rest in range(N+1):
            for k in range(rest-K+1):
                dp[bit][rest-k] += dp[bit+1][rest] * cmb(rest,k,mod) * pow_2[k*bit]
                dp[bit][rest-k] %= mod
    else:
        #bit目が立っているのがrest-K+1個以上
        for rest in range(N+1):
            for k in range(rest-K+1,rest+1):
                dp[bit][rest] += dp[bit+1][rest] * cmb(rest,k,mod)
                dp[bit][rest] %= mod

print(sum(dp[0])%mod)
0