結果

問題 No.1710 Minimum OR is X
ユーザー chineristACchineristAC
提出日時 2021-08-17 20:24:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 2,678 bytes
コンパイル時間 1,352 ms
コンパイル使用メモリ 81,624 KB
実行使用メモリ 82,120 KB
最終ジャッジ日時 2023-10-17 19:55:00
合計ジャッジ時間 5,228 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
69,024 KB
testcase_01 AC 66 ms
69,024 KB
testcase_02 AC 103 ms
81,776 KB
testcase_03 AC 65 ms
69,028 KB
testcase_04 AC 63 ms
69,028 KB
testcase_05 AC 65 ms
69,028 KB
testcase_06 AC 66 ms
69,028 KB
testcase_07 AC 64 ms
69,028 KB
testcase_08 AC 115 ms
82,040 KB
testcase_09 AC 114 ms
81,832 KB
testcase_10 AC 116 ms
81,808 KB
testcase_11 AC 116 ms
81,800 KB
testcase_12 AC 115 ms
81,828 KB
testcase_13 AC 119 ms
81,800 KB
testcase_14 AC 119 ms
81,820 KB
testcase_15 AC 104 ms
82,040 KB
testcase_16 AC 116 ms
82,040 KB
testcase_17 AC 110 ms
81,776 KB
testcase_18 AC 121 ms
82,040 KB
testcase_19 AC 127 ms
82,040 KB
testcase_20 AC 124 ms
81,820 KB
testcase_21 AC 130 ms
82,120 KB
testcase_22 AC 129 ms
82,040 KB
testcase_23 AC 67 ms
69,028 KB
testcase_24 AC 65 ms
69,028 KB
testcase_25 AC 66 ms
69,176 KB
testcase_26 AC 123 ms
81,972 KB
testcase_27 AC 67 ms
69,176 KB
testcase_28 AC 115 ms
81,900 KB
testcase_29 AC 66 ms
69,176 KB
testcase_30 AC 100 ms
82,092 KB
testcase_31 AC 66 ms
69,176 KB
testcase_32 AC 115 ms
81,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
omega = pow(3,119,mod)
rev_omega = pow(omega,mod-2,mod)

N = 2*10**5
g1 = [1]*(N+1) # 元テーブル
g2 = [1]*(N+1) #逆元テーブル
inv = [1]*(N+1) #逆元テーブル計算用テーブル

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

def _ntt(f,L,reverse=False):
    F=[f[i] for i in range(L)]
    n = L.bit_length() - 1
    base = omega
    if reverse:
        base = rev_omega

    if not n:
        return F

    size = 2**n
    wj = pow(base,2**22,mod)
    res = [0]*2**n

    for i in range(n,0,-1):
        use_omega = pow(base,2**(22+i-n),mod)
        res = [0]*2**n
        size //= 2
        w = 1
        for j in range(0,L//2,size):
            for a in range(size):
                res[a+j] = (F[a+2*j] + w * F[a+size+2*j]) % mod
                t = (w * wj) % mod
                res[L//2+a+j] = (F[a+2*j] + t * F[a+size+2*j]) % mod
            w = (w * use_omega) % mod
        F = res

    return res

def ntt(f,L=0):
    l = len(f)
    if not L:
        L = 1<<((l-1).bit_length())
    while len(f)<L:
        f.append(0)
    f=f[:L]
    F = _ntt(f,L)
    return F

def intt(f,L=0):
    l = len(f)
    if not L:
        L = 1<<((l-1).bit_length())
    while len(f)<L:
        f.append(0)
    f=f[:L]
    F = _ntt(f,L,reverse=True)
    inv = pow(L,mod-2,mod)
    for i in range(L):
        F[i] *= inv
        F[i] %= mod
    return F

def convolve(f,g,limit):
    l = len(f)+len(g)-1
    L = 1<<((l-1).bit_length())

    F = ntt(f,L)
    G = ntt(g,L)

    H = [(F[i] * G[i]) % mod for i in range(L)]

    h = intt(H,L)

    return h[:limit]

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    return (g1[n] * g2[r] % mod) * g2[n-r] % 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()

comb_cum = [0 for i in range(N+1)]
comb_cum[0] = 1
for i in range(1,N+1):
    comb_cum[i] = (2 * comb_cum[i-1] + cmb(i-1,K,mod) - cmb(i,K,mod)) % mod

dp = [0 for j in range(N+1)]
dp[N] = 1
for bit in range(M-1,-1,-1):
    t = pow(2,bit,mod)
    if X[M-1-bit]=="0":
        f = [g2[k] * pow(t,k,mod) % mod for k in range(N+1)[::-1]]
        dp = convolve(f,dp,2*N+1)[N:2*N+1]
    else:
        dp = [dp[rest] * comb_cum[rest] % mod for rest in range(N+1)]
                
ans = sum(dp[rest]*(g1[N]*g2[rest] % mod) % mod for rest in range(K,N+1)) % mod
print(ans)
0