結果

問題 No.1313 N言っちゃダメゲーム (4)
ユーザー ああいいああいい
提出日時 2022-04-14 22:22:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 267 ms / 2,000 ms
コード長 1,708 bytes
コンパイル時間 391 ms
コンパイル使用メモリ 86,728 KB
実行使用メモリ 87,164 KB
最終ジャッジ日時 2023-08-25 23:49:09
合計ジャッジ時間 9,488 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
70,856 KB
testcase_01 AC 71 ms
71,128 KB
testcase_02 AC 72 ms
71,124 KB
testcase_03 AC 72 ms
71,320 KB
testcase_04 AC 72 ms
71,276 KB
testcase_05 AC 72 ms
70,996 KB
testcase_06 AC 73 ms
71,204 KB
testcase_07 AC 72 ms
71,136 KB
testcase_08 AC 72 ms
71,024 KB
testcase_09 AC 73 ms
71,220 KB
testcase_10 AC 73 ms
71,128 KB
testcase_11 AC 73 ms
71,176 KB
testcase_12 AC 72 ms
71,276 KB
testcase_13 AC 197 ms
86,808 KB
testcase_14 AC 242 ms
87,020 KB
testcase_15 AC 267 ms
87,164 KB
testcase_16 AC 234 ms
84,512 KB
testcase_17 AC 171 ms
82,528 KB
testcase_18 AC 212 ms
82,936 KB
testcase_19 AC 220 ms
82,636 KB
testcase_20 AC 135 ms
78,124 KB
testcase_21 AC 167 ms
79,624 KB
testcase_22 AC 157 ms
79,872 KB
testcase_23 AC 192 ms
81,496 KB
testcase_24 AC 138 ms
78,172 KB
testcase_25 AC 204 ms
83,472 KB
testcase_26 AC 126 ms
78,268 KB
testcase_27 AC 158 ms
79,588 KB
testcase_28 AC 217 ms
83,196 KB
testcase_29 AC 232 ms
83,020 KB
testcase_30 AC 235 ms
84,848 KB
testcase_31 AC 222 ms
83,348 KB
testcase_32 AC 239 ms
85,556 KB
testcase_33 AC 205 ms
83,372 KB
testcase_34 AC 215 ms
83,092 KB
testcase_35 AC 168 ms
86,212 KB
testcase_36 AC 197 ms
84,268 KB
testcase_37 AC 207 ms
83,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #


class SegTree:
    #単位元と結合演算はここ変える
    #いろんな種類のsegは作れないかも
    #→changeで変えれる
    
    unit = 1 << 30
    def f(self,x,y):
        return min(x,y)

    #頂点は1-index、一番下の段は0-index(bitは1-index)
    def __init__(self,N):
        self.N = N
        self.X = [self.unit] * (N + N)
    def build(self,seq):
        for i,x in enumerate(seq,self.N):
            self.X[i] = x
        for i in range(self.N-1,0,-1):
            self.X[i] = self.f(self.X[i << 1],self.X[i << 1 | 1])
    def set(self,i,x):
        i += self.N
        self.X[i] = x
        while i > 1:
            i >>= 1
            self.X[i] = self.f(self.X[i << 1],self.X[i << 1 | 1])
    def fold(self,L,R):
        #区間[L,R)についてfold
        #0 <= L,R <= N にしなきゃダメ
        L += self.N
        R += self.N
        vL = self.unit
        vR = self.unit
        while L < R:
            if L & 1:
                vL = self.f(vL,self.X[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.f(self.X[R],vR)
            L >>= 1
            R >>= 1
        return self.f(vL,vR)
    def change(self,f,unit):
        self.f = f
        self.unit = unit

N,K = map(int,input().split())
S = input()
seg = SegTree(N + K)
seq = [1] * (N + K)
seg.build(seq)
for i in range(N - 1,-1,-1):
    tmp = seg.fold(i + 1,i + 1 + K)
    if i > 0 and S[i-1]== "o":
        seg.set(i,1 - tmp)
    if i == 0:
        seg.set(0,1 - tmp)
import sys
if seg.fold(0,1) == 0:
    print(0)
    exit()
else:
    ans = []
    for i in range(1,K+1):
        if seg.fold(i,i+1) == 0:
            ans.append(i)
    print(*ans)
0