結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,376 KB
testcase_01 WA -
testcase_02 AC 39 ms
53,376 KB
testcase_03 AC 39 ms
53,376 KB
testcase_04 AC 38 ms
53,376 KB
testcase_05 AC 39 ms
53,376 KB
testcase_06 AC 39 ms
53,376 KB
testcase_07 AC 39 ms
53,376 KB
testcase_08 AC 39 ms
53,376 KB
testcase_09 AC 40 ms
53,376 KB
testcase_10 WA -
testcase_11 AC 39 ms
53,376 KB
testcase_12 AC 40 ms
53,376 KB
testcase_13 AC 92 ms
89,220 KB
testcase_14 WA -
testcase_15 AC 129 ms
89,216 KB
testcase_16 AC 137 ms
89,216 KB
testcase_17 AC 130 ms
89,480 KB
testcase_18 AC 115 ms
84,156 KB
testcase_19 AC 112 ms
83,508 KB
testcase_20 AC 74 ms
76,688 KB
testcase_21 AC 100 ms
81,296 KB
testcase_22 AC 88 ms
78,936 KB
testcase_23 WA -
testcase_24 AC 76 ms
76,472 KB
testcase_25 AC 108 ms
84,172 KB
testcase_26 AC 59 ms
68,300 KB
testcase_27 AC 88 ms
80,784 KB
testcase_28 WA -
testcase_29 AC 129 ms
89,276 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 130 ms
89,540 KB
testcase_33 AC 101 ms
89,220 KB
testcase_34 AC 100 ms
89,220 KB
testcase_35 AC 91 ms
89,220 KB
testcase_36 AC 96 ms
89,220 KB
testcase_37 AC 96 ms
89,220 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])
f = 0
for i in range(1, K + 1):
  if dp[i] == 0:
    print(i)
    f = 1
if f == 0: print(0)
0