Problem:


Score : 500 points

Problem Statement

Takahashi has decided to work on K days of his choice from the N days starting with tomorrow.

You are given an integer C and a string S. Takahashi will choose his workdays as follows:

After working for a day, he will refrain from working on the subsequent C days.

If the i-th character of S is x, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on.

Find all days on which Takahashi is bound to work.

Constraints

1 \leq N \leq 2 \times 10^5

1 \leq K \leq N

0 \leq C \leq N

The length of S is N.

Each character of S is o or x.

Takahashi can choose his workdays so that the conditions in Problem Statement are satisfied.

Input

Input is given from Standard Input in the following format:

N K C
S

Output

Print all days on which Takahashi is bound to work in ascending order, one per line.

Sample Input 1

11 3 2
ooxxxoxxxoo

Sample Output 1

6

Takahashi is going to work on 3 days out of the 11 days. After working for a day, he will refrain from working on the subsequent 2 days.

There are four possible choices for his workdays: Day 1,6,10, Day 1,6,11, Day 2,6,10, and Day 2,6,11.

Thus, he is bound to work on Day 6.

Sample Input 2

5 2 3
ooxoo

Sample Output 2

1
5

There is only one possible choice for his workdays: Day 1,5.

Sample Input 3

5 1 0
ooooo

Sample Output 3

There may be no days on which he is bound to work.

Sample Input 4

16 4 3
ooxxoxoxxxoxoxxo

Sample Output 4

11
16



Sample input:
11 3 2
ooxxxoxxxoo


Sample output:
6

Submission status: Runtime Error

Solution code:
n,k,c=[int(x) for x in input().split()]
s=list(input())

L=[]
R=[]
i=0
while i < n:
    
    if s[i]=="o":
        L.append(i)
        i+=2
    i+=1

i=0
while i < n:
    
    if s[n-i-1]=="o":
        R.append(n-i-1)
        i+=2
    i+=1
    


days=[]

for i in range(k):
    
    if L[i]==R[i]:
        days.append(L[i])

for i in range(len(days)):
    print(days[i])

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-*-

from sys import stdin
import collections


def is_workable(K: int, C: int, S: list) -> bool:
    cnt = 0
    yasumi = 0
    for s in S:
        if yasumi > 0 or s == "x":
            yasumi -= 1
        elif s == "o":
            cnt += 1
            yasumi = C

        # check
        if cnt >= K:
            return True
    return False


def main():
    N, K, C = list(map(int, stdin.readline().split()))
    S = int(stdin.readline())
    # N 全体の日数
    # K 働く日数
    # C 休む中日
    # S すでに入ってる予定

    must_work = []
    if is_workable(K, C, S):
        for i, s in enumerate(S):
            if s == "x":
                continue
            if i == 0:
                S2 = "x" + S[i + 1:]
            elif i == N - 1:
                S2 = S[:i] + "x"
            else:
                S2 = S[:i] + "x" + S[i + 1:]

            if not is_workable(K, C, S2):
                must_work.append(i + 1)

        for m in must_work:
            print(m)



if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def is_workable(K: int, C: int, S: list) -> bool:
    cnt = 0
    yasumi = 0
    for s in S:
        if yasumi > 0 or s == "x":
            yasumi -= 1
        elif s == "o":
            cnt += 1
            yasumi = C

        # check
        if cnt >= K:
            return True
    return False
  
    must_work = []
    # 働けるなら1日ずつxに変えてみる
    if is_workable(K, C, S):
        for i, s in enumerate(S):
            if s == "x":
                continue
            if i == 0:
                S2 = "x" + S[i + 1:]
            elif i == N - 1:
                S2 = S[:i] + "x"
            else:
                S2 = S[:i] + "x" + S[i + 1:]

            if not is_workable(K, C, S2):
                must_work.append(i + 1)

        for m in must_work:
            print(m)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
n, k, c = list(map(int, input().split()))
s = input()

set1 = set()
set2 = set()
index = 0
cnt = 0
while index < n and cnt < c:
    if s[index] == 'o':
        set1.add(index + 1)
        index += c + 1
        cnt += 1
        continue
    else:
        index += 1

index = n - 1
cnt = 0
while index < n and cnt < c:
    if s[index] == 'o':
        set2.add(index + 1)
        index -= c + 1
        cnt += 1
        continue
    else:
        index -= 1

res_set = set1 & set2
for i in sorted(res_set):
    print(i)

Submission status: Runtime Error

Solution code:
N, K, C = map(int, input().split())
S = input()
L = []
R = []
L_index = 0
L_count = 0
R_index = N - 1
R_count = K - 1

while L_index < N and L_count < K:
    if S[L_index] == "o":
        L.append(L_index)
        L_index += (C + 1)
        L_count += 1
    else:
        L_index += 1
while R_index >= 0 and R_count >= 0:
    if S[R_index] == "o":
        R.append(R_index)
        R_index -= (C - 1)
        R_count -= 1
    else:
        R_index -= 1

work_day = set(L) & set(R)
for w_day in work_day:
    print(w_day + 1)

Submission status: Runtime Error

Solution code:
from itertools import combinations
import numpy as np

N, K, C = map(int, input().split())
S = input()

indexes=[i+1 for i,s in enumerate(S) if s=='o']

results=[]
for c in combinations(indexes,K):
    if np.diff(c).min() < C+1 :continue
    results.append(set(c))
    
for num in set.intersection(*results):
    print(num)

Submission status: Runtime Error

Solution code:
n,k,c= map(int,input().split())
s = input()
i = 0

def func(s,k,c):
  i = 0
  res = []
  while 1:
    if s[i] == 'o':
      res.append(i)
      if len(ans1)== k:
        break
      i += c
  return res
ans1 = set(func(s,k,c))
ans2 = set(func(s[::-1],k,c))

ans = list(ans1.intersection(ans2))
for a in ans:
  print(a)

Submission status: Runtime Error

Solution code:
n,k,c = list(map(int, input().split()))
s = input()
ls = list(s)

ortho = [0]*k
rever = [0]*k

a = 0
skip = []
for i in range(len(ls)):
    if ls[i] == "o" and i not in skip:
        ortho[a] = i
        a += 1
        skip = [i+j for j in range(1, c+1)]

a = 0
skip = []
ls.reverse()
for i in range(len(ls)):
    if ls[i] == "o" and i not in skip:
        rever[a] = i
        a += 1
        skip = [i+j for j in range(1, c+1)]

rever.reverse()
rever = [len(ls)-1-i for i in rever]

for i in range(k):
    if ortho[i] == rever[i]:
        print(ortho[i])

Submission status: Runtime Error

Solution code:
nkc=input().split()
K=int(nkc[1])
C=int(nkc[2])
s=input()
workday_list=[]
for i,youso in enumerate(s) :
  if youso=='o' :
    workday_list.append(i+1)
    

s=1

current_num=0
current_num1=1
list1=[]
list1.append(workday_list[0])
while(s<K) :
  
  if current_num1>=len(workday_list):
    break
  elif workday_list[current_num1]-workday_list[current_num]>C :
    current_num=current_num1
    list1.append(workday_list[current_num1])
    s+=1
  else :
    current_num1=current_num1+1
m=1  

current_num2=len(workday_list)-1
current_num3=len(workday_list)-2
list2=[]
list2.append(workday_list[-1])
while(m<K) :
  
  if current_num3<=0:
    break
  elif workday_list[current_num2]-workday_list[current_num3]>C :
    current_num2=current_num3
    list2.append(workday_list[current_num3])
    m+=1
  else :
    current_num3=current_num3-1

list2.reverse()
flag=True
for i in range(len(list1)) :
  if list1[i]==list2[i] :
    flag=False
    print(list1[i])
if flag :
  print()

Submission status: Runtime Error

Solution code:
nkc=input().split()
K=int(nkc[1])
C=int(nkc[2])
s=input()
workday_list=[]
for i,youso in enumerate(s) :
  if youso=='o' :
    workday_list.append(i+1)
    

s=1

current_num=0
current_num1=1
list1=[]
list1.append(workday_list[0])
while(s<K) :
  
  if current_num1>=len(workday_list):
    break
  elif workday_list[current_num1]-workday_list[current_num]>C :
    current_num=current_num1
    list1.append(workday_list[current_num1])
    s+=1
  else :
    current_num1=current_num1+1
m=1  

current_num2=len(workday_list)-1
current_num3=len(workday_list)-2
list2=[]
list2.append(workday_list[-1])
while(m<K) :
  
  if current_num3<=0:
    break
  elif workday_list[current_num2]-workday_list[current_num3]>C :
    current_num2=current_num3
    list2.append(workday_list[current_num3])
    m+=1
  else :
    current_num3=current_num3-1

list2.reverse()

for i in range(len(list1)) :
  if list1[i]==list2[i] :
    print(list1[i])

Submission status: Runtime Error

Solution code:
nkc=input().split()
K=int(nkc[1])
C=int(nkc[2])
s=input()
workday_list=[]
for i,youso in enumerate(s) :
  if youso=='o' :
    workday_list.append(i+1)
    

s=1

current_num=0
current_num1=1
list1=[]
list1.append(workday_list[0])
while(s<K) :
  
  if current_num1>=len(workday_list):
    break
  elif workday_list[current_num1]-workday_list[current_num]>C :
    current_num=current_num1
    list1.append(workday_list[current_num1])
    s+=1
  else :
    current_num1=current_num1+1
m=1  

current_num2=len(workday_list)-1
current_num3=len(workday_list)-2
list2=[]
list2.append(workday_list[-1])
while(m<K) :
  
  if current_num3<=0:
    break
  elif workday_list[current_num2]-workday_list[current_num3]>C :
    current_num2=current_num3
    list2.append(workday_list[current_num3])
    m+=1
  else :
    current_num3=current_num3-1

list2.reverse()
print(list1)
print(list2)
for i in range(len(list1)) :
  if list1[i]==list2[i] :
    print(list1[i])

Submission status: Runtime Error

Solution code:
nkc=input().split()
K=int(nkc[1])
C=int(nkc[2])
s=input()
workday_list=[]
for i,youso in enumerate(s) :
  if youso=='o' :
    workday_list.append(i+1)
    

s=0

current_num=0
current_num1=1
list1=[]
list1.append(workday_list[0])
while(s<=K) :
  
  if current_num1>=len(workday_list):
    break
  elif workday_list[current_num1]-workday_list[current_num]>C :
    current_num=current_num1
    list1.append(workday_list[current_num1])
    s+=1
  else :
    current_num1=current_num1+1
m=0  

current_num2=len(workday_list)-1
current_num3=len(workday_list)-2
list2=[]
list2.append(workday_list[-1])
while(m<K) :
  
  if current_num3<=0:
    break
  elif workday_list[current_num2]-workday_list[current_num3]>C :
    current_num2=current_num3
    list2.append(workday_list[current_num3])
    m+=1
  else :
    current_num3=current_num3-1

list2.reverse()

for i in range(len(list1)) :
  if list1[i]==list2[i] :
    print(list1[i])

Submission status: Runtime Error

Solution code:
nkc=input().split()
K=int(nkc[1])
C=int(nkc[2])
s=input()
workday_list=[]
for i,youso in enumerate(s) :
  if youso=='o' :
    workday_list.append(i+1)
    

s=0

current_num=0
current_num1=1
list1=[]
list1.append(workday_list[0])
while(s<=K) :
  
  if current_num1>=len(workday_list):
    break
  elif workday_list[current_num1]-workday_list[current_num]>=C :
    current_num=current_num1
    list1.append(workday_list[current_num1])
    s+=1
  else :
    current_num1=current_num1+1
m=0  

current_num2=len(workday_list)-1
current_num3=len(workday_list)-2
list2=[]
list2.append(workday_list[-1])
while(m<K) :
  
  if current_num3<=0:
    break
  elif workday_list[current_num2]-workday_list[current_num3]>=C :
    current_num2=current_num3
    list2.append(workday_list[current_num3])
    m+=1
  else :
    current_num3=current_num3-1

list2.reverse()

for i in range(len(list1)) :
  if list1[i]==list2[i] :
    print(list1[i])

Submission status: Runtime Error

Solution code:
N, K, C = map(int, input().split())
S = input().strip()
dp1 = [0]*(N+2)
dp2 = [0]*(N+2)
c = 10*18
cc = 0
for i in range(N):
    if S[i] == "o" and c >= C:
        cc += 1
        c = 0
    else:
        c += 1
    dp1[i+1] = cc
c = 10*18
cc = 0
for i in range(N-1, -1, -1):
    if S[i] == "o" and c >= C:
        cc += 1
        c = 0
    else:
        c += 1
    dp2[i+1] = cc
rs = []
for i in range(N):
    if S[i+1] == "o" and dp1[i] + dp2[i+2] == K-1:
        rs.append(i+1)

#print(dp1, dp2)
for r in rs:
    print(r)

Submission status: Runtime Error

Solution code:
import sys

N,K,C=map(int,input().split())

S=list(input())
left=[0]*N
right=[0]*N

if S[0]=="o":
    left[0]=1
for i in range(1,C+1):
    left[i]=left[i-1]
    if S[i]=="o":
        left[i]=1
for i in range(C+1,N):
    if S[i]=="o":
        left[i]=max(left[i-1],left[i-C-1]+1)
    else:
        left[i]=left[i-1]

if S[-1]=="o":
    right[-1]=1
for i in range(N-2,N-C-2,-1):
    right[i]=right[i+1]
    if S[i]=="o":
        right[i]=1
for i in range(N-C-2,-1,-1):
    if S[i]=="o":
        right[i]=max(right[i+1],right[i+C+1]+1)
    else:
        right[i]=right[i+1]

data=[]
for i in range(N):
    if S[i]=="o":
        L=i-C-1
        R=i+C+1
        num=1
        if L>=0:
            num+=left[L]
        if R<N:
            num+=right[R]
        if num>K:
            sys.exit()
        if num==K:
            data.append(i)

for i in range(len(data)):
    if i==0:
        if data[i+1]-data[i]>C:
            print(data[i]+1)
    elif i==len(data)-1:
        if data[i]-data[i-1]>C:
            print(data[i]+1)
    else:
        if data[i+1]-data[i]>C and data[i]-data[i-1]>C:
            print(data[i]+1)

Submission status: Runtime Error

Solution code:
n,k,c=map(int, input().split())
s=input()
L=[]
R=[]
m=0
for i in range(k):
    while s[m]=="x":
        m+=1
    if s[m]=="o":
        L.append(m)
        m+=c
    m+=1
m=0
for i in range(k):
    while s[m]=="x":
        m+=1
    if s[n-m-1]=="o":
        R.insert(0,n-m-1)
        m+=c
    m+=1
for i in range(k):
    if R[i]==L[i]:
        print(R[i]+1)

Submission status: Runtime Error

Solution code:
n,k,c=map(int, input().split())
s=input()
L=[]
R=[]
m=0
for i in range(k):
    while s[m]=="x":
        m+=1
    if s[m]=="o":
        L.append(m)
        m+=c
    m+=1
m=0
for i in range(k):
    while s[m]=="x":
        m+=1
    if s[n-m-1]=="o":
        R.append(n-m-1)
        m+=c
    m+=1
for i in range(k):
    if R[i]==L[i]:
        print(R[i]+1)

Submission status: Runtime Error

Solution code:
N, K, C = map(int, input().split())
S = str(input())

#前から貪欲に
x = 0
L = [-1] * N
p = 0
while x < N:
  if S[x] == "o":
    L[p] = x
    p += 1
    x += C + 1
  else:
    x += 1

#後ろから貪欲に    
y = N - 1
R = [-1] * N
q = 0
while y > -1:
  if S[y] == "o":
    R[q] = y
    q += 1
    y -= C + 1
  else:
    y -= 1
    
#print(L, R)    
L_1 = L.index(-1)
L = L[:L_1]
R = R[:L_1]
N = len(L)

#LとRの被っている数に1足したものを出力
for i in range(N):
  if L[i] == R[N - i - 1]:
    print(L[i] + 1)

Submission status: Runtime Error

Solution code:
N,K,C=map(int,input().split())
S=input()
L=[0 for i in range(K)]
R=[0 for i in range(K)]
n=0
rc=0
lc=0
while True:
  if lc==K:
    break
  if S[n]=="o":
    L[lc]=n+1
    n+=C+1
    lc+=1
  else:
    n+=1
n=N-1
while True:
  if rc==K:
    break
  if S[n]=="o":
    R[N-1-rc]=n+1
    n-=C+1
    rc+=1
  else:
    n-=1
for i in range(K):
  if R[i]==L[i]:
    print(R[i])

Submission status: Runtime Error

Solution code:
n,k,c=map(int,input().split())
s=input()
#働く日のうちi日目についてそれ以後でないと働けない日をL[i]とする配列を考える
#働く日のうちi日目についてそれ以前でないと働けない日をR[i]とする配列も考える
#その二つが同じとき、必ず働かなければいけない日になる
#L[i]があった時、L[i]+c+1以降からしか働けないことに注意(vice versa)

#バグ？なんで？
l=[-1]*k
r=[-1]*k
nowl=0
indl=0
while nowl<n and indl<k:
    for i in range(nowl,n):
        if s[i]=="o":
            l[indl]=i
            nowl=i+c+1
            indl+=1
            break
nowr=n-1
indr=k-1
while nowr>=0 and indr>=0:
    for i in range(nowr,-1,-1):
        if s[i]=="o":
            r[indr]=i
            nowr=i-c-1
            indr-=1
            break
for i in k:
    if l[i]==r[i]:
        print(i+1)

Submission status: Runtime Error

Solution code:
N, K, C = map(int, input().split())
S = input()

Sr = "".join(list(reversed(S)))

wd = []
wdl = []

pw = 0
pwl = 0

for d in range(K):

    # 先詰めを探す
    while True:
        if S[pw] == ('o'):
            wd.append(pw)
            break
        pw += 1
    pw += C + 1
    
    # 後詰めを探す
    while True:
        if Sr[pwl] == ('o'):
            wdl.append(pwl)
            break
        pwl += 1
    pwl += C + 1

en = time.time()

wdl.sort()
    
for i in range(K):
    if wd[i] == wdl[i]:
        print(wd[i] + 1)

Submission status: Runtime Error

Solution code:
n, k, c = map(int, input().split())
s = list(input())
cnt = s.count('o')
os = [i for i,x in enumerate(s) if x=='o']

from collections import deque

q = deque(os.copy())
_q1 = q.popleft()
m = k-1
l = [_q1]
if m > 0:
    while q:
        _q2 = q.popleft()
        if _q2 - _q1 > c:
            l.append(_q2)
            _q1 = _q2
            m -= 1
            if m == 0:
                q = deque([])
        else:
            pass

q = deque(os.copy())
_q2 = q.pop()
m = k-1
r = [_q2]
if m > 0:
    while q:
        _q1 = q.pop()
        if _q2 - _q1 > c:
            r.append(_q1)
            _q2 = _q1
            m -= 1
            if m == 0:
                q = deque([])
        else:
            pass

r = list(reversed(r))

ans = 0
for _l, _r in zip(l, r):
    if _l == _r:
        print(str(_l+1))
        ans = 1

if ans == 0:
    print()

Submission status: Runtime Error

Solution code:
n, k, c = map(int, input().split())
s = list(input())
cnt = s.count('o')
os = [i for i,x in enumerate(s) if x=='o']

from collections import deque

q = deque(os.copy())
_q1 = q.popleft()
m = k-1
l = [_q1]
while q and m > 0:
    _q2 = q.popleft()
    if _q2 - _q1 > c:
        l.append(_q2)
        _q1 = _q2
        m -= 1
        if m == 0:
            q = deque([])
    else:
        pass

q = deque(os.copy())
_q2 = q.pop()
m = k-1
r = [_q2]
while q and m > 0:
    _q1 = q.pop()
    if _q2 - _q1 > c:
        r.append(_q1)
        _q2 = _q1
        m -= 1
        if m == 0:
            q = deque([])
    else:
        pass

r = list(reversed(r))

# print(r)

ans = 0
for _l, _r in zip(l, r):
    if _l == _r:
        print(str(_l+1))
        ans = 1

if ans == 0:
    print()

Submission status: Runtime Error

Solution code:
n, k, c = map(int, input().split())
s = list(input())
cnt = s.count('o')
os = [i for i,x in enumerate(s) if x=='o']

from collections import deque

q = deque(os.copy())
_q1 = q.popleft()
m = k-1
l = [_q1]
while q and m > 0:
    _q2 = q.popleft()
    if _q2 - _q1 > c:
        l.append(_q2)
        _q1 = _q2
        m -= 1
        if m == 0:
            q = deque([])
    else:
        pass

q = deque(os.copy())
_q2 = q.pop()
m = k-1
r = [_q2]
while q and m > 0:
    _q1 = q.pop()
    if _q2 - _q1 > c:
        r.append(_q1)
        _q2 = _q1
        m -= 1
        if m == 0:
            q = deque([])
    else:
        pass

r = list(reversed(r))

# print(r)

ans = 0
for _l, _r in zip(l, r):
    if _l == _r:
        print(_l+1)
        ans = 1

Submission status: Runtime Error

Solution code:
n, k, c = map(int, input().split())
s = list(input())
cnt = s.count('o')
os = [i for i,x in enumerate(s) if x=='o']

from collections import deque

q = deque(os.copy())
_q1 = q.popleft()
m = k-1
l = [_q1]
while q and m > 0:
    _q2 = q.popleft()
    if _q2 - _q1 > c:
        l.append(_q2)
        _q1 = _q2
        m -= 1
        if m == 0:
            q = deque([])
    else:
        pass

# print(l)

q = deque(os.copy())
_q2 = q.pop()
m = k-1
r = [_q2]
while q and m > 0:
    _q1 = q.pop()
    if _q2 - _q1 > c:
        r.append(_q1)
        _q2 = _q1
        m -= 1
        if m == 0:
            q = deque([])
    else:
        pass

r = list(reversed(r))

# print(r)

ans = 0
for _l, _r in zip(l, r):
    if _l == _r:
        print(_l+1)
        ans = 1

if ans == 0:
    print()

Submission status: Runtime Error

Solution code:
n, k, c = map(int, input().split())
s = input()

l, r = [], []
cur = 0
count = 0

while cur <= n:
    if s[cur] == "o":
        count += 1
        l.append((count, cur+1))
        cur += c

    cur += 1

cur = n
count = k

while cur >= 0:
    if s[cur] == "o":
        r.append((count, cur+1))
        count -= 1
        cur -= c

    cur -= 1

ans = (i[1] for i in set(l) & set(r))
for i in sorted(ans):
    print(i)

Submission status: Runtime Error

Solution code:
# import time

N, K, C = list(map(int, input().split()))
S = list(input())

F = []
L = []

# t1 = time.time()
# for i in range(N):
#     if S[i] == 'o':
#         if len(F) == 0:
#             F.append(i)
#         elif F[-1] + C < i:
#             F.append(i)
#     if len(F) >= K:
#         break
# print(F)
# t2 = time.time()
i = 0
while len(F) < K and i < N:
    if S[i] == 'o':
        if len(F) == 0:
            F.append(i)
        elif F[-1] + C < i:
            F.append(i)
    i += 1
# print(F)
# t3 = time.time()

# print(t2 - t1, t3 - t2)

i = N - 1
while len(L) < K and i >= 0:
    if S[i] == 'o':
        if len(L) == 0:
            L.append(i)
        elif L[-1] - C > i:
            L.append(i)
    i -= 1

if len(F) == K and len(L) == K:
    ans = [i + 1 for i in set(F) &

Submission status: Runtime Error

Solution code:
n,k,c = map(int, input().split())
s = input()

# 計算途中は0~N-1日とする

# [a,b] i日までで、限界まで働くとa回働けてb日まで働けない
pre = [[0,0] for i in range(n)]
if s[0]=='o':
    pre[0]=[1,c]
    for j in range(c):
        if 1+j < n:
            pre[1+j] = pre[0] + []

for i in range(1,n):
    if pre[i]==[0,0]:
        if s[i]=='o':
            pre[i][0]=pre[i-1][0]+1
            pre[i][1]+=i+c
            for j in range(c):
                if i+j+1<n:
                    pre[i+j+1]=pre[i]+[]
        else:
            pre[i]=pre[i-1]+[]

# i日以降で限界まで働くとa回働ける
post = [0 for i in range(n)]
if s[-1]=='o':
    post[-1]=1
    for j in range(c):
        if 0 <= n-1-j-1 < n:
            post[-1-j-1] = post[-1]

for i in range(1,n):
    if post[n-i-1]==0:
        if s[n-i-1]=='o':
            post[n-i-1]=post[n-i]+1
            for j in range(c):
                if 0<=n-i-1-j-1<n:
                    post[n-i-1-j-1]=post[n-i-1]
        else:
            post[n-i-1]=post[n-i]

# 0日、n+1日を追加。iを1~nにする
pre = [[0,0]]+pre+[[0,0]]
post = [0]+post+[0]

ans = []
for i in range(1,n+1):
    if s[i-1]=='o':
        work, rest = pre[i-1]
        day = max(rest,i)+1
        work = work + post[day]
        if work<k:
            ans.append(i)

for i in range(len(ans)):
    print(ans[i])

Submission status: Runtime Error

Solution code:
n,k,c = map(int, input().split())
s = input()

# 計算途中は0~N-1日とする

# [a,b] i日までで、限界まで働くとa回働けてb日まで働けない
pre = [[0,0] for i in range(n)]
if s[0]=='o':
    pre[0]=[1,c]
    for j in range(c):
        if 1+j < n:
            pre[1+j] = pre[0] + []

for i in range(1,n):
    if pre[i]==[0,0]:
        if s[i]=='o':
            pre[i][0]=pre[i-1][0]+1
            pre[i][1]+=i+c
            for j in range(c):
                if i+j+1<n:
                    pre[i+j+1]=pre[i]+[]
        else:
            pre[i]=pre[i-1]+[]

# i日以降で限界まで働くとa回働ける
post = [0 for i in range(n)]
if s[-1]=='o':
    post[-1]=1
    for j in range(c):
        if 0 <= n-1-j-1 < n:
            post[-1-j-1] = post[-1]

for i in range(1,n):
    if post[n-i-1]==0:
        if s[n-i-1]=='o':
            post[n-i-1]=post[n-i]+1
            for j in range(c):
                if 0<=n-i-1-j-1<n:
                    post[n-i-1-j-1]=post[n-i-1]
        else:
            post[n-i-1]=post[n-i]

# 0日、n+1日を追加。iを1~nにする
pre = [[0,0]]+pre+[[0,0]]
post = [0]+post+[0]

ans = []
for i in range(1,n+1):
    work, rest = pre[i-1]
    day = max(rest,i)+1
    work = work + post[day]
    if work<k:
        ans.append(i)

for i in range(len(ans)):
    print(ans[i])

Submission status: Runtime Error

Solution code:
N, K, C = map(int, input().split())
S = input()
L, R = [0]*N, [0]*N
i = 0
count = 1
while count <= K:
    if S[i] == 'x':
        i += 1
        continue
    L[i] = count
    count += 1
    i += C+1
i = N-1
count = K
while count >= 0:
    if S[i] == 'x':
        i -= 1
        continue
    R[i] = count
    count -= 1
    i -= C+1
for i in range(N):
    if L[i] == 0:
        continue
    if L[i] == R[i]:
        print(i+1)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>

using namespace std;
using ll = int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using tpi = tuple<int, int, int>;

using vqi = vector<queue<int>>;
using vpi = vector<pii>;
using bs = bitset<60>;
using vbi = vector<bs>;

ll gcd(ll a, ll b) {
    if (a < b) {
        swap(a, b);
    }

    /* ユークリッドの互除法 */
    ll r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

constexpr int64_t __pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    if (p == 0) {
        return 1;
    }
    if (p % 2 == 0) {
        int64_t t = __pow_mod(n, p / 2, mod);
        return (t * t) % mod;
    }
    return (n * (__pow_mod(n, p - 1, mod) % mod)) % mod;
}

constexpr int64_t pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    int64_t res = __pow_mod(n, p, mod);
    if (res == 0) {
        res = mod;
    }
    return res;
}

constexpr int64_t nCr_mod(int64_t n, int64_t r, int64_t mod) noexcept {
    int64_t count = 1;
    auto a = r;
    for (auto i = n; i > n - r; i--) {
        count *= i;
        if (count % mod != 0) {
            count %= mod;
        }
        int64_t inv = pow_mod(a, mod - 2, mod);
        count *= inv;
        if (count % mod != 0) {
            count %= mod;
        }
        a--;
    }
    return count;
}

void solve(long long N, long long K, long long C, std::string S) {
    list<ll> L, R;
    for (ll i = 0; i < S.length(); i++) {
        if (S[i] == 'o') {
            L.push_back(i + 1);
            i += C;
        }
        if (L.size() == K) {
            break;
        }
    }
    for (ll i = S.length() - 1; i >= 0; i--) {
        if (S[i] == 'o') {
            R.push_front(i + 1);
            i -= C;
        }
        if (R.size() == K) {
            break;
        }
    }

    auto l = L.cbegin();
    auto r = R.cbegin();

    for (auto i = 0; i < L.size(); i++) {
        if (*l == *r) {
            cout << *l << endl;
        }
        l++;
        r++;
    }
}

int main() {
    long long N;
    std::cin >> N;
    long long K;
    std::cin >> K;
    long long C;
    std::cin >> C;
    std::string S;
    std::cin >> S;
    solve(N, K, C, S);
    return 0;
}

Submission status: Runtime Error

Solution code:
# coding: utf-8

def search(worked= [],idx=0):
    if len(worked) == K:
        patterns.append(worked)
        return None
    _workable = workable[idx:]
    if _workable == []:
        return None
    for i, _work in enumerate(_workable,1):
        if worked==[]:
            search(worked + [_work], idx+i)
            continue
        if _work < worked[-1]:
            continue
        if _work <= worked[-1] + C:
            continue
        search(worked + [_work], idx+1)

def extract(S):
    ret = []
    for idx, s in enumerate(S, 1):
        if s == 'o':
            ret.append(idx)
    return ret

if __name__ == '__main__':
    N, K, C = list(map(int, input().split()))
    S = list(input())
    workable = extract(S)
    patterns = []
    search()
    workwork = []
    judge = True
    for day in patterns[0]:
        for pattern in patterns[1:]:
            if day in pattern:
                judge = True
            else:
                judge = False
                break
        if judge:
            workwork.append(day)
    for v in workwork:
        print(v)

Submission status: Runtime Error

Solution code:
# coding: utf-8

def search_next(work_days, omit_day, cur_day, patterns):
    if len(work_days) == K:
        patterns.append(work_days)
        return None
    if cur_day == N+1:
        return None
    if omit_day[cur_day-1] == 'x':
        search_next(work_days, omit_day, cur_day+1, patterns)
        return None

    for w_ in (True, False):
        omit = omit_day.copy()
        work = work_days.copy()
        if w_:
            if omit[cur_day-1] == 'o':
                work.append(cur_day)
                omit[cur_day:cur_day+C] = ['x'] * C
                search_next(work, omit, cur_day+1, patterns)
        else:
            search_next(work, omit, cur_day+1, patterns)


if __name__ == '__main__':
    N, K, C = list(map(int, input().split()))
    S = list(input())
    patterns = []
    search_next([], S, 1, patterns)
    workwork = []
    judge = True
    for day in patterns[0]:
        for pattern in patterns[1:]:
            if day in pattern:
                judge = True
            else:
                judge = False
                break
        if judge:
            workwork.append(day)
    for v in workwork:
        print(v)

Submission status: Runtime Error

Solution code:
# E - Yutori
from typing import List


def find_workdays(
    total_days: int, workdays_length: int, days_off_length: int, schedule: List[bool]
) -> List[int]:
    if days_off_length == 0:
        workdays = [i for i, can_work in enumerate(schedule, 1) if can_work]
        return workdays if len(workdays) <= workdays_length else []

    workdays_left, workdays_right = [], []

    for workdays, gen in [
        (workdays_left, enumerate(schedule, 1)),
        (workdays_right, ((total_days - i, x) for i, x in enumerate(schedule[::-1]))),
    ]:
        days_off = 0
        for i, can_work in gen:
            if days_off:
                days_off -= 1
                continue
            if can_work:
                workdays.append(i)
                days_off = days_off_length
                if len(workdays) == workdays_length:
                    break

    return [l for l, r in zip(workdays_left, workdays_right[::-1]) if l == r]


def main():
    N, K, C = map(int, input().split())
    S = input().rstrip()
    workdays = find_workdays(N, K, C, [s == "o" for s in S])
    print("\n".join(map(str, workdays)))


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
# coding: utf-8

def search_next(work_days, omit_day, cur_day, patterns):
    if len(work_days) == K:
        patterns.append(work_days)
    if cur_day == N+1:
        return None
    for w_ in (True, False):
        omit = omit_day.copy()
        work = work_days.copy()
        if w_:
            if omit[cur_day-1] == 'o':
                work.append(cur_day)
                omit[cur_day:cur_day+C] = ['x'] * C
                search_next(work, omit, cur_day+1, patterns)
        else:
            search_next(work, omit, cur_day+1, patterns)


if __name__ == '__main__':
    N, K, C = list(map(int, input().split()))
    S = list(input())
    patterns = []
    search_next([], S, 1, patterns)
    workwork = []
    judge = True
    for day in patterns[0]:
        for pattern in patterns[1:]:
            if day in pattern:
                judge = True
            else:
                judge = False
                break
        if judge:
            workwork.append(day)
    for v in workwork:
        print(v)

Submission status: Runtime Error

Solution code:
N,K,C=map(int,input().split())
SL=input()
SR=SL[::-1]
Left=[]
Right=[]
Last=-N
Rast=-N
cL=cR=0
for i in range(N):
    if SL[i]=="o" and i-Last>C and cL<=K:
        Left.append(i)
        Last=i
        cL+=1
    if SR[i]=="o" and i-Rast>C and cR<=K:
        Right.append(N-i-1)
        Rast=i
        cR+=1
Right=Right[::-1]

ans=[]

for k in range(K):
    if Left[k]==Right[k]:
        ans.append(Left[k]+1)

if len(ans)==0:
    print()
else:
    for a in ans:
        print(a)

Submission status: Runtime Error

Solution code:
N,K,C=map(int,input().split())
SL=input()
SR=SL[::-1]
Left=[]
Right=[]
Last=-N
Rast=-N
cL=cR=0
for i in range(N):
    if SL[i]=="o" and i-Last>C and cL<=K:
        Left.append(i)
        Last=i
        cL+=1
    if SR[i]=="o" and i-Rast>C and cR<=K:
        Right.append(N-i-1)
        Rast=i
        cR+=1
Right=Right[::-1]

ans=[]

for k in range(K):
    if Left[k]==Right[k]:
        ans.append(Left[k]+1)
print(ans)