結果

問題 No.1710 Minimum OR is X
ユーザー shotoyooshotoyoo
提出日時 2021-10-15 22:02:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 104 ms / 2,000 ms
コード長 1,683 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 81,788 KB
実行使用メモリ 76,252 KB
最終ジャッジ日時 2023-10-17 20:19:11
合計ジャッジ時間 3,387 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
59,612 KB
testcase_01 AC 44 ms
59,612 KB
testcase_02 AC 69 ms
69,140 KB
testcase_03 AC 44 ms
59,612 KB
testcase_04 AC 44 ms
59,612 KB
testcase_05 AC 43 ms
59,612 KB
testcase_06 AC 45 ms
59,612 KB
testcase_07 AC 44 ms
59,612 KB
testcase_08 AC 78 ms
71,184 KB
testcase_09 AC 76 ms
71,212 KB
testcase_10 AC 81 ms
71,184 KB
testcase_11 AC 74 ms
71,176 KB
testcase_12 AC 93 ms
76,252 KB
testcase_13 AC 74 ms
71,176 KB
testcase_14 AC 80 ms
73,248 KB
testcase_15 AC 70 ms
71,188 KB
testcase_16 AC 92 ms
76,252 KB
testcase_17 AC 71 ms
71,184 KB
testcase_18 AC 97 ms
73,276 KB
testcase_19 AC 89 ms
73,284 KB
testcase_20 AC 75 ms
71,184 KB
testcase_21 AC 98 ms
73,276 KB
testcase_22 AC 104 ms
73,276 KB
testcase_23 AC 45 ms
59,612 KB
testcase_24 AC 45 ms
59,612 KB
testcase_25 AC 55 ms
64,220 KB
testcase_26 AC 47 ms
61,860 KB
testcase_27 AC 46 ms
61,860 KB
testcase_28 AC 62 ms
66,500 KB
testcase_29 AC 55 ms
64,220 KB
testcase_30 AC 45 ms
59,812 KB
testcase_31 AC 46 ms
61,860 KB
testcase_32 AC 60 ms
66,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))
# sys.setrecursionlimit(3*10**5+10)

n,m,k = list(map(int, input().split()))
x = list(map(int, input()))
M = 998244353
N = 10**4 # 必要なテーブルサイズ
g1 = [0] * (N+1) # 元テーブル
g2 = [0] * (N+1) #逆元テーブル
inverse = [0] * (N+1) #逆元テーブル計算用テーブル
g1[0] = g1[1] = g2[0] = g2[1] = 1
inverse[0], inverse[1] = [0, 1] 
for i in range( 2, N + 1 ):
    g1[i] = ( g1[i-1] * i ) % M 
    inverse[i] = ( -inverse[M % i] * (M//i) ) % M # ai+b==0 mod M <=> i==-b*a^(-1) <=> i^(-1)==-b^(-1)*aより
    g2[i] = (g2[i-1] * inverse[i]) % M 
def cmb(n, r, M=M):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return ((g1[n] * g2[r] % M) * g2[n-r]) % M
def perm(n, r, M=M):
    if (r<0 or r>n):
        return 0
    return (g1[n] * g2[n-r]) % M
v2 = [1]
for _ in range(1000):
    v2.append(v2[-1]*2%M)
dp = [0]*(n+1) # 候補がi個
dp[n] = 1
for i in range(m):
    ndp = [0]*(n+1)
    if x[i]==0:
        for j in range(n+1):
            val = dp[j]
            if val==0:
                continue
            for nj in range(k, j+1):
                ndp[nj] += val * (cmb(j, nj) * v2[n-j] % M) % M
                ndp[nj] %= M
    else:
        for j in range(n+1):
            val = dp[j]
            if val==0:
                continue
            tmp = 0
            for v in range(k):
                tmp += cmb(j, v)
                tmp %= M
            ndp[j] += val * (v2[n-j] * tmp % M) % M
    dp = ndp
ans = sum(dp)%M
print(ans%M)
0