結果

問題 No.1313 N言っちゃダメゲーム (4)
ユーザー wolgnikwolgnik
提出日時 2020-12-10 02:05:37
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,063 bytes
コンパイル時間 1,549 ms
コンパイル使用メモリ 81,328 KB
実行使用メモリ 89,424 KB
最終ジャッジ日時 2023-10-19 12:31:47
合計ジャッジ時間 4,669 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,328 KB
testcase_01 WA -
testcase_02 AC 41 ms
53,328 KB
testcase_03 AC 40 ms
53,328 KB
testcase_04 AC 40 ms
53,328 KB
testcase_05 AC 40 ms
53,328 KB
testcase_06 AC 41 ms
53,328 KB
testcase_07 AC 40 ms
53,328 KB
testcase_08 AC 40 ms
53,328 KB
testcase_09 AC 40 ms
53,328 KB
testcase_10 WA -
testcase_11 AC 39 ms
53,328 KB
testcase_12 AC 39 ms
53,328 KB
testcase_13 AC 93 ms
89,060 KB
testcase_14 WA -
testcase_15 AC 134 ms
89,100 KB
testcase_16 AC 141 ms
89,100 KB
testcase_17 AC 135 ms
89,364 KB
testcase_18 AC 114 ms
84,040 KB
testcase_19 AC 112 ms
83,392 KB
testcase_20 AC 73 ms
76,552 KB
testcase_21 AC 101 ms
81,180 KB
testcase_22 AC 89 ms
78,820 KB
testcase_23 WA -
testcase_24 AC 77 ms
76,348 KB
testcase_25 AC 111 ms
84,056 KB
testcase_26 AC 62 ms
68,168 KB
testcase_27 AC 91 ms
80,668 KB
testcase_28 WA -
testcase_29 AC 128 ms
89,160 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 133 ms
89,424 KB
testcase_33 AC 103 ms
89,104 KB
testcase_34 AC 103 ms
89,104 KB
testcase_35 AC 93 ms
89,104 KB
testcase_36 AC 97 ms
89,104 KB
testcase_37 AC 97 ms
89,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
N, K = map(int, input().split())
S = list(input())[: -1]
dp = [0] * (N + 1)

class FenwickTree:
  def __init__(self, n):
    self.n = n
    self.data = [0] * (n + 2)
  def sum(self, l, r):
    s = 0
    while l > 0:
      s -= self.data[l]
      l -= l & -l
    while r > 0:
      s += self.data[r]
      r -= r & -r
    return s
  def add(self, i, x):
    i += 1
    while i <= self.n:
      self.data[i] += x
      i += i & -i
  def lowerbound(self, s):
    x = 0
    y = 0
    for i in range(self.n.bit_length(), -1, -1):
      k = x + (1 << i)
      if k <= self.n and (y + self.data[k] < s):
        y += self.data[k]
        x += 1 << i
    return x + 1

fwk = FenwickTree(N)
fwk.add(N, 1)
dp[-1] = 1
if S[-1] == "x":
  dp[-2] = 1
  fwk.add(N - 1, 1)
for i in range(N - 2, -1, -1):
  if S[i - 1] == "x":
    dp[i] = 1
    fwk.add(i, 1)
    continue
  r = min(N, i + K)
  s = fwk.sum(i, r + 1)
  if s < r - i: dp[i] = 1
  fwk.add(i, dp[i])
for i in range(1, K + 1):
  if dp[i] == 0:
    print(i)
    break
else: print(0)
0