結果

問題 No.1710 Minimum OR is X
ユーザー wolgnikwolgnik
提出日時 2021-10-16 13:06:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 372 ms / 2,000 ms
コード長 1,201 bytes
コンパイル時間 862 ms
コンパイル使用メモリ 81,616 KB
実行使用メモリ 75,948 KB
最終ジャッジ日時 2023-10-17 22:09:49
合計ジャッジ時間 4,722 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,428 KB
testcase_01 AC 37 ms
53,428 KB
testcase_02 AC 83 ms
75,660 KB
testcase_03 AC 37 ms
53,428 KB
testcase_04 AC 38 ms
53,428 KB
testcase_05 AC 37 ms
53,428 KB
testcase_06 AC 38 ms
53,428 KB
testcase_07 AC 37 ms
53,428 KB
testcase_08 AC 100 ms
75,764 KB
testcase_09 AC 104 ms
75,700 KB
testcase_10 AC 118 ms
75,888 KB
testcase_11 AC 87 ms
75,632 KB
testcase_12 AC 154 ms
75,828 KB
testcase_13 AC 113 ms
75,700 KB
testcase_14 AC 128 ms
75,696 KB
testcase_15 AC 84 ms
75,948 KB
testcase_16 AC 148 ms
75,948 KB
testcase_17 AC 72 ms
73,152 KB
testcase_18 AC 260 ms
75,716 KB
testcase_19 AC 171 ms
75,948 KB
testcase_20 AC 73 ms
72,632 KB
testcase_21 AC 314 ms
75,888 KB
testcase_22 AC 372 ms
75,744 KB
testcase_23 AC 39 ms
53,428 KB
testcase_24 AC 38 ms
53,428 KB
testcase_25 AC 43 ms
59,716 KB
testcase_26 AC 38 ms
53,428 KB
testcase_27 AC 50 ms
62,212 KB
testcase_28 AC 67 ms
68,444 KB
testcase_29 AC 43 ms
59,716 KB
testcase_30 AC 38 ms
53,428 KB
testcase_31 AC 48 ms
62,212 KB
testcase_32 AC 67 ms
68,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
N, M, K = map(int, input().split())
X = list(map(int, list(input())[: -1]))
mod = 998244353

class Factorial:
  def __init__(self, n, mod):
    self.mod = mod
    self.f = [1]
    for i in range(1, n + 1): self.f.append(self.f[-1] * i % mod)
    self.i = [pow(self.f[-1], mod - 2, mod)]
    for i in range(1, n + 1)[: : -1]: self.i.append(self.i[-1] * i % mod)
    self.i.reverse()
  def factorial(self, i): return self.f[i]
  def ifactorial(self, i): return self.i[i]
  def combi(self, n, k): return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod
  def permi(self, n, k): return self.f[n] * self.i[n - k] % self.mod

f = Factorial(N, mod)

dp = [0] * (N - K + 1)

dp[-1] = 1
for i in range(M):
  x = X[i]
  for j in range(N - K + 1):
    if x:
      t = 0
      for k in range(1, K + 1):
        t += f.combi(K + j, j + k)
        t %= mod
        #print(i, j, k, (K + j, j + k), t)
      dp[j] *= t * pow(2, N - j - K, mod)
      dp[j] %= mod
    else:
      for k in range(j):
        dp[k] += dp[j] * f.combi(K + j, j - k) * pow(2, N - j - K, mod)
        dp[k] %= mod
      dp[j] *= pow(2, N - j - K, mod)
      dp[j] %= mod
print(sum(dp) % mod)
0