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: Time Limit Exceeded

Solution code:
# coding: utf-8

def possible(K, C, workable):
    if workable == []:return False
    work_day = 1
    pre_day = workable[0]
    if workable[1:] == []:
        if work_day == K:
            return True
    for work in workable[1:]:
        if pre_day + C >= work:
            continue
        pre_day = work
        work_day += 1
        if work_day == K:
            return True
    return False

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())
    base = extract(S)
    if not possible(K,C,base):
        _ = ''
    else:
        for i in range(len(base)):
            workable = base.copy()
            del workable[i]
            if not possible(K , C, workable):
                print(base[i])

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

S_OK = [i for i, x in enumerate(S) if x == 'o']
SF, SL = S_OK.copy(), S_OK.copy()
F = []
L = []

for j in range(K):
    F.append(SF[0])
    SF = [i for i in SF if SF[0] + C < i]
    L.insert(0, SL[-1])
    SL = [i for i in SL if SL[-1] - C > i]

[print(i + 1) for i in set(F) & set(L)]

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

S_OK = [i for i, x in enumerate(S) if x == 'o']
SF, SL = S_OK.copy(), S_OK.copy()
F = []
L = []

for j in range(K):
    F.append(SF[0])
    SF = [i for i in SF if SF[0] + C < i]
    L.insert(0, SL[-1])
    SL = [i for i in SL if SL[-1] - C > i]

[print(i + 1) for i in F if i in L]

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

S_OK = [i for i, x in enumerate(S) if x == 'o']
SF, SL = S_OK.copy(), S_OK.copy()
F = []
L = []

for j in range(K):
    F.append(SF[0])
    SF = [i for i in SF if SF[0] + C < i]
    L.insert(0, SL[-1])
    SL = [i for i in SL if SL[-1] - C > i]

# del F[-1]
# del L[0]

for i in F:
    if i in L:
        print(i+1)

Submission status: Time Limit Exceeded

Solution code:
N, K, C = list(map(int, input().split(" ")))
S = input()
S_list = [i for i in S]

F_list = []
B_list = []
count = 0
for j in range(K):
    for i in range(count, len(S_list)):
        if S_list[i] == "o":
            F_list.append(i+1)
            count += C+1
            break
        else:
            count += 1
S_list = S_list[::-1]

count = 0
for j in range(K):
    for i in range(count, len(S_list)):
        if S_list[i] == "o":
            B_list.append(len(S_list)-i)
            count += C+1
            break
        else:
            count += 1

for i in F_list:
    if i in B_list:
        print(i)

Submission status: Time Limit Exceeded

Solution code:
import itertools
 
N, K, C = map(int, input().split())
S = input()
 
days = [i+1 for i, x in enumerate(S) if x == 'o']
 
wp = list(itertools.combinations(days,K))
wList =[]
 
for w in wp:
  w = list(w)
  isContinue = False
  for sub in range(len(w)-1):
    if w[sub+1] - w[sub] <= C:
      isContinue = True
  if isContinue == False:
    wList.append(w)
 
#tp = map(tuple, wList)
#qty = map(lambda x: tp.count(x), tuple(tp))
#print(set(wList[1]) & set([6]))
#print(set(wList[1] & set(6)))
 
ans = wList[0]
for i in wList:
  ans = (set(i) & set(list(ans)))
 
ans = sorted(list(ans))
for i in ans:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
N, K, C = map(int, input().split())
I = input()
P = [1 if I[i] == 'o' else 0 for i in range(N)]

L = []
R = []

d = 0
while len(L) < K:
	if P[d] == 1:
		L.append(d+1)
		d += C+1
	else:
		d += 1
d = N-1
while len(R) < K:
	if P[d] == 1:
		R.append(d+1)
		d -= C+1
	else:
		d -= 1

ans = []
for l in L:
	if l in R:
		ans.append(l)

if ans:
	for a in ans:
		print(a)
else:
	print()

Submission status: Time Limit Exceeded

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

L = [-1] * K
R = [-1] * K
S_index = 0
count = 0
while count < K:
  if S[S_index] == "o":
    L[count] = S_index
    count += 1
    S_index += C+1
  else:
    S_index += 1

S_index = N-1
count = 0
while count < K:
  if S[S_index] == "o":
    R[count] = S_index
    count += 1
    S_index -= C+1
  else:
    S_index -= 1

for l in L:
  if l in R:
    print(l+1)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
'''
16 4 3
ooxxoxoxxxoxoxxo

output
11
16
'''

import numpy as np
import sys

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

oks = [idx for idx, i in enumerate(S) if i == 'o']
# print(oks)

temp = np.array(oks)
# 逆向きは反転させて、その向きで計算した上で日付を戻す
temp_reverse = (N - 1 - np.array(oks))[::-1]

# print(temp, temp_reverse)


def calc(data: np.ndarray, reverse: bool = False):
    count_dict = {}
    cnt = 0
    while True:
        idx = data[0]
        data = data[data > idx + C]

        if cnt <= K:
            if not reverse:
                count_dict[cnt + 1] = idx + 1
            else:
                count_dict[K - cnt] = N - 1 - idx + 1
        else:
            sys.exit()
        cnt += 1
        if len(data) == 0:
            break

    return count_dict


this = calc(temp)
reverse = calc(temp_reverse, reverse=True)

# print(this, reverse)
ans = list(set(this.values()) & set(reverse.values()))
ans.sort()
[print(i) for i in ans]

Submission status: Time Limit Exceeded

Solution code:
nkc=list(map(int, input().split()))
s=input()
n=nkc[0]
k=nkc[1]
c=nkc[2]
l=[]
r=[]
onum=sum(1 for i in range(len(s)) if s[i]=='o')
num=0
counter=0
while counter<k and num<n:
    #print(num)
    if s[num]=='o':
        l.append(num)
        counter+=1
        num+=c+1
    else:
        num+=1
num=n-1
counter=0
while counter<k and num>=0:
    #print(num)
    if s[num]=='o':
        r.insert(0,num)
        counter+=1
        num-=c+1
    else:
        num-=1
#print(l)
#print(r)
for i in range(min(len(r), len(l))):
    if r[i]==l[i]:
        print(r[i]+1)

Submission status: Time Limit Exceeded

Solution code:
import copy
N,K,C= map(int,input().split())
S = input()
T = [n for n, v in enumerate(S) if v == "o"]

a,b=[T[0]],[T[-1]]

for i in range(len(T)):
  if len(a)==K and len(b)==K:
    break
  if len(a)!=K:
    if T[i]-a[-1]>C:
      a.append(T[i])
  if len(b)!=K:
    if b[0]-T[-i-1]>C:
      b.insert(0,T[-i-1])
      
for i in range(K):
  if a[i]==b[i]:
    print(a[i]+1)

Submission status: Time Limit Exceeded

Solution code:
import copy
N,K,C= map(int,input().split())
S = input()
T = [n for n, v in enumerate(S) if v == "o"]

a,b=[T[0]],[T[-1]]

for i in range(len(T)):
  if len(a)!=K:
    if T[i]-a[-1]>C:
      a.append(T[i])
  if len(b)!=K:
    if b[0]-T[-i-1]>C:
      b.insert(0,T[-i-1])
      
for i in range(K):
  if a[i]==b[i]:
    print(a[i]+1)

Submission status: Time Limit Exceeded

Solution code:
nkc=list(map(int, input().split()))
s=input()
n=nkc[0]
k=nkc[1]
c=nkc[2]
for i in range(len(s)):
    if s[i]=='o':
        sw=s
        sw=sw[:i]+'x'+sw[i+1:]
        counter=0
        num=0
        while counter<k and num<n:
            #print(num)
            if sw[num]=='o':
                counter+=1
                num+=c+1
            else:
                num+=1
        if counter<k:
            print(i+1)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from itertools import combinations

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

work = range(1, n + 1)
not_working = [i for i, v in enumerate(s, start=1) if v == "x"]

working = sorted(set(work) - set(not_working))


def is_consistent(t):
    u = t[1:]
    for i, v in zip(t, u):
        if v - i <= c:
            return False
    return True


l = filter(is_consistent, combinations(working, k))
for i in sorted(reduce(lambda a, b: set(a) & set(b), l)):
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n,k,c = map(int, input().split())
s = str(input())
t = []
u = []
i,x,y,j = 0,0,0,n-1
while i < n and x < k:
    if s[i] == "o":
        t.append(i)
        x += 1
        i += c
    i += 1

while j >= 0 and y < k:
    if s[j] == "o":
        u.insert(0,j)
        y += 1
        j += -c
    j += -1

for i in range(0,k):
    if t[i] == u[i]:
        print(t[i]+1)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from itertools import combinations

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

work = range(1, n + 1)
not_working = []
for i, v in enumerate(s, start=1):
    if v == "o":
        continue
    not_working.append(i)

working = sorted(set(work) - set(not_working))


def is_consistent(t):
    u = t[1:]
    for i, v in zip(t, u):
        if v - i <= c:
            return False
    return True


l = filter(is_consistent, combinations(working, k))
for i in sorted(reduce(lambda a, b: set(a) & set(b), l)):
    print(i)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from itertools import combinations

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

work = range(1, n + 1)
not_working = []
for i, v in enumerate(s, start=1):
    if v == "o":
        continue
    not_working.append(i)

working = set(work) - set(not_working)


def is_consistent(t):
    t = sorted(t)
    u = t[1:]
    for i, v in zip(t, u):
        if v - i <= c:
            return False
    return True


l = filter(is_consistent, combinations(working, k))
for i in sorted(reduce(lambda a, b: set(a) & set(b), l)):
    print(i)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
'''
11 3 2
ooxxxoxxxoo
'''

import numpy as np

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

oks = [idx for idx, i in enumerate(S) if i == 'o']
# print(oks)

for ok in oks:
    temp = oks.copy()
    temp.remove(ok)
    temp = np.array(temp)
    cnt = 0

    while True:
        if len(temp) == 0:
            print(ok + 1)
            break
        val = temp[0]
        temp = temp[temp > val + C]
        cnt += 1
        if cnt >= K:
            break

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)


def dfs(n, rest):
    global C, N
    rst = 0
    if maxR[n] > 0:
        rst = maxR[n]
    elif rest >= C and S[n] == 'o':
        rst += 1
        if n + (C + 1) < N:
            rst += dfs(n + C + 1, C)
    else:
        if n + 1 < N:
            rst += dfs(n + 1, rest + 1)
    return rst


def dfs2(n, rest):
    global C, N
    rst = 0
    if maxL[n] > 0:
        rst = maxL[n]
    elif rest >= C and S[n] == 'o':
        rst += 1
        if n - (C + 1) >= 0:
            rst += dfs2(n - (C + 1), C)
    else:
        if n - 1 >= 0:
            rst += dfs2(n - 1, rest + 1)
    return rst


N, K, C = map(int, input().split())
S = input()
maxR = [-1] * N
for i in range(N):
    if S[i] == 'o' and maxR[i] == -1:
        maxR[i] = dfs(i, C)

if maxR[-1] == -1:
    maxR[-1] = 0
for i in range(N - 2, -1, -1):
    if maxR[i] == -1:
        maxR[i] = maxR[i + 1]

maxL = [-1] * N
for i in range(N - 1, -1, -1):
    if S[i] == 'o' and maxL[i] == -1:
        maxL[i] = dfs2(i, C)

if maxL[0] == -1:
    maxL[0] = 0
for i in range(1, N):
    if maxL[i] == -1:
        maxL[i] = maxL[i - 1]

ans = []
for i in range(N):
    r = maxR[i + 1] if i + 1 < N else 0
    l = maxL[i - 1] if i - 1 >= 0 else 0
    if r + l < K:
        ans.append(i + 1)

print(*ans, sep='\n')

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
n, k, c = map(int, input().split())
s = input()
candidate = []
result=[]

for i in range(k):
    tmp_cand = []
    start = 1 + (c+1)*(i)
    end = n-(c+1)*(k-i-1)
#    print("s: " + str(start) + ", e: " + str(end))
    for j in range(start-1, end):
        if s[j] == "o":
            tmp_cand.append(j+1)
#    print(tmp_cand)
    candidate.append(tmp_cand)

for idx, ci in enumerate(candidate):
#    print(idx)
    if len(ci) == 1:
        print(ci[0])
        if idx < len(candidate)-1:
            next_cand = candidate[idx+1]
#            print("ci[0]: " + str(ci[0]))
            t_n_cand = [nc_i for nc_i in next_cand if nc_i >= ci[0] + c+1]
#            print(t_n_cand)
            candidate[idx+1] = t_n_cand

Submission status: Time Limit Exceeded

Solution code:
N,K,C = [int(i.strip()) for i in input().split(' ')]
S = input()
s = []
for i,v in enumerate(S):
    if v == 'o':
        s.append(i)

tmp2 = s.copy()
for i in s:
    tmp = s.copy()
    tmp.remove(i)
    count = 0
    for j,v in enumerate(tmp):
        if j == 0:
            b = v+ C
            count += 1
        if j > 0:
            # print(v)
            if b < v:
                b = v+ C
                count += 1
    # print(count)
    if count >= K:
        tmp2.remove(i)


for i in tmp2:
    print(i+1)

Submission status: Time Limit Exceeded

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

l=[]
la=[]
i=0
c=0
while True:
    if S[i]=="o":
        l.append(i)
        i+=C
        c+=1
    i+=1
    if i>=N:
        break

if c>K:
    exit()

i=N-1
c=0

while True:
    if S[i]=="o":
        la.append(i)
        i-=C
        c+=1
    i-=1
    if c==K:
        break
    
for i in l:
    if i in la:
        print(i+1)

Submission status: Time Limit Exceeded

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

s = input()
now = 0
left = []
right = []
cnt = 0
while (1):
    if s[now] == 'o':
        left.append(now)
        now += c + 1
        cnt += 1
    else:
        now += 1
    if now >= len(s) or cnt == k:
        break

sr = s[::-1]

now = 0
cnt = 0
while (1):
    if sr[now] == 'o':
        right.append(len(s) - now - 1)
        now += c + 1
        cnt += 1
    else:
        now += 1
    if now >= len(s) or cnt == k:
        break

# print(left)
# print(right)

for i in left:
    if i in right:
        print(i + 1)

Submission status: Time Limit Exceeded

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

l=[]
la=[]
i=0
c=0
while True:
    if S[i]=="o":
        l.append(i)
        i+=C
        c+=1
    i+=1
    if c==K:
        break

i=N-1
c=0

while True:
    if S[i]=="o":
        la.append(i)
        i-=C
        c+=1
    i-=1
    if c==K:
        break
    
for i in l:
    if i in la:
        print(i+1)

Submission status: Time Limit Exceeded

Solution code:
n, k, c = map(int, input().split())
s = input()
s2 = s
s += "x"*c
s2 = "x"*c+s2
k2 = k
left = []
i = 0
while i < n:
  if k == 0:
    break
  if s[i] == "o":
    left.append(i+1)
    s = "x"*(i+c+1)+s[i+c+1:]
    #print(s)
    k -= 1
    i += c
  i += 1

right = []
i = len(s2)-1
while i >= 0:
  if k2 == 0:
    break
  if s2[i] == "o":
    right.append(i+1-c)
    s2 = s2[:i-c]+"x"*(len(s2)-i+c)
    #print(s2)
    k2 -= 1
    i -= c
  i -= 1
#print(left, right)
 
ans = sorted(list(set(left) & set(right)))
for i in ans:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
def main():
    n,k,c=map(int,input().split())
    s=list(input())[::-1]
    sl=[0 if i=='x' else 1 for i in s]
    chk=int(''.join(map(str,sl)),2)
    ans=0
    for i in range(2**(n+1)):
        if i&chk==0:
            continue
        ocnt,cnt,bcnt,f=0,0,0,0
        for j in range(len(bin(i))-1):
            cnt+=1
            if i>>j&1:
                ocnt+=1
                if bcnt!=0:
                    if cnt-bcnt<=c:
                        f=1
                        break
                if ocnt>k:
                    f=1
                    break
                bcnt=cnt
        if f==0 and ocnt==k:
            if chk&i==i:
                if ans==0:
                    ans=i
                else:
                    ans=ans&i
                    if ans==0:
                        exit()
    for i in range(len(bin(ans))-1):
        if ans>>i&1:
            print(i+1)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    n,k,c=map(int,input().split())
    s=list(input())[::-1]
    sl=[0 if i=='x' else 1 for i in s]
    chk=int(''.join(map(str,sl)),2)
    ans=0
    for i in range(2**(n+1)):
        ocnt,cnt,bcnt,f=0,0,0,0
        for j in range(len(bin(i))-1):
            cnt+=1
            if i>>j&1:
                ocnt+=1
                if bcnt!=0:
                    if cnt-bcnt<=c:
                        f=1
                        break
                if ocnt>k:
                    f=1
                    break
                bcnt=cnt
        if f==0 and ocnt==k:
            if chk&i==i:
                if ans==0:
                    ans=i
                else:
                    ans=ans&i
                    if ans==0:
                        exit()
    for i in range(len(bin(ans))-1):
        if ans>>i&1:
            print(i+1)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
  n, k, c = map(int, input().split())
  ss = list(input())
  
  wd = [i for i, e in enumerate(ss) if e == 'o']
  wd_flg = [True for _ in wd]
  
  used = [0]
  cur = wd[0]
  if k != 1:
    for i, e in enumerate(wd):
      if e > cur + c:
        used.append(i)
        cur = e
        if len(used) == k:
          break
          
  used_rev = [len(wd)-1]
  cur = wd[-1]
  if k != 1: 
    for i, e in enumerate(wd[::-1]):
      if e < cur - c:
        used_rev.append(len(wd) - 1 - i)
        cur = e
        if len(used_rev) == k:
          break
  
  for i in used:
    if i not in used_rev:
      continue
    if used.index(i) + used_rev.index(i) >= k:
      continue
    else:
      print(wd[i]+1)
  
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

wd = [i for i, e in enumerate(ss) if e == 'o']
wd_flg = [True for _ in wd]

used = [0]
cur = wd[0]
if k != 1:
  for i, e in enumerate(wd):
    if e > cur + c:
      used.append(i)
      cur = e
      if len(used) == k:
        break
        
used_rev = [len(wd)-1]
cur = wd[-1]
if k != 1: 
  for i, e in enumerate(wd[::-1]):
    if e < cur - c:
      used_rev.append(len(wd) - 1 - i)
      cur = e
      if len(used_rev) == k:
        break

for i in used:
  if i not in used_rev:
    continue
  if used.index(i) + used_rev.index(i) >= k:
    continue
  else:
    print(wd[i]+1)

Submission status: Time Limit Exceeded

Solution code:

# -*- coding: utf-8 -*-

import copy 
N, K, C=map(int, input().split())
s=list(input())


for i in range(N):
    if s[i]=='o':
        si=copy.copy(s)
        si[i]='x'
        day=N
        count=0
        flag=False
        while day>0 and day>=K-count and count<K:
            if si[day-1]=='x':
                day-=1
            else:
                count+=1
                day-=C+1
                if count==K:
                    flag=True
        if flag==False:
            print(i+1)

Submission status: Time Limit Exceeded

Solution code:

# -*- coding: utf-8 -*-

import copy 
N, K, C=map(int, input().split())
s=list(input())


for i in range(N):
    if s[i]=='o':
        si=copy.copy(s)
        si[i]='x'
        day=N
        count=0
        flag=False
        while day>0 and count<K:
            if si[day-1]=='x':
                day-=1
            else:
                count+=1
                day-=C+1
                if count==K:
                    flag=True
        if flag==False:
            print(i+1)

Submission status: Time Limit Exceeded

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

    if c == 0:
        if s.count('o') == k:
            ret = [i for i, c in enumerate(s) if c == 'o']
        else:
            ret = []

    else:

        go = set()
        back = set()

        i = 0
        while i < n:
            if s[i] == 'o':
                go.add(i)
                if len(go) == k:
                    break
                i += c + 1
            else:
                i += 1

        if len(go) < k:
            return

        i = n - 1
        while i >= 0:
            if s[i] == 'o':
                back.add(i)
                if len(back) == k:
                    break
                i -= c + 1
            else:
                i -= 1

        if len(back) < k:
            return

        isec = go & back

        ret = []
        for elm in isec:
            go = set()
            i = 0
            while i < n:
                if i == elm:
                    i += 1
                    continue

                if s[i] == 'o':
                    go.add(i)
                    if len(go) == k:
                        break
                    i += c + 1
                else:
                    i += 1

            if len(go) < k:
                ret.append(elm)

    print(*map(lambda x: x + 1, ret), sep='\n')


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

import numpy as np

n,k,c = mi()
s = input()
am = s.count('o') - k
def isClear(s):
    cnt = n-1
    wa = 0 #work available
    tam = am-1
    
    while 1:
        if s[cnt] == 'o':
            st = max(0,cnt-c)
            tam -= s[st:cnt].count('o')
            wa+=1
            cnt-=c+1
        else:
            cnt-=1        
        if wa == k: return 1
        if tam < 0: return 0
        if cnt<=-1: return 0

ans = []
for i in range(n):
    if s[i] == 'x':
        continue
    else:
        ss = s[:i] + 'x' + s[i+1:]
        if isClear(ss) == 0:
            ans.append(i+1)
for i in ans:
    print(i)

Submission status: Time Limit Exceeded

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

    go = set()
    back = set()

    i = 0
    while i < n:
        if s[i] == 'o':
            go.add(i)
            if len(go) == k:
                break
            i += c + 1
        else:
            i += 1

    if len(go) < k:
        return

    i = n - 1
    while i >= 0:
        if s[i] == 'o':
            back.add(i)
            if len(back) == k:
                break
            i -= c + 1
        else:
            i -= 1

    if len(back) < k:
        return

    isec = go & back

    ret = []
    for elm in isec:
        go = set()
        i = 0
        while i < n:
            if i == elm:
                i += 1
                continue

            if s[i] == 'o':
                go.add(i)
                if len(go) == k:
                    break
                i += c + 1
            else:
                i += 1

        if len(go) < k:
            ret.append(elm)

    print(*map(lambda x: x + 1, ret), sep='\n')


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def calc(N, K, C, S):
    ans = set([i for i in range(N)])
    memo = {-N * 2: [[]]}
    for i in [j for j in range(N) if S[j] == 'o']:
        new_memo = dict(memo)
        for key in memo:
            if i - key > C:
                for m in memo[key]:
                    x = [i] + m
                    if len(x) == K:
                        ans = ans & set(x)
                    else:
                        new_memo[i] = (new_memo[i] if i in new_memo else []) + [x]
        if not ans:
            break
        memo = new_memo
    return '\n'.join([str(i + 1) for i in ans])



(N, K, C) = tuple([int(s) for s in input().split()])
S = input()
print(calc(N, K, C, S))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
n, k, c = map(int, input().split())
s = input()
candidate = []
result=[]

for i in range(k):
    tmp_cand = []
    start = 1 + (c+1)*(i)
    end = n-(c+1)*(k-i-1)
#    print("s: " + str(start) + ", e: " + str(end))
    for j in range(start-1, end):
        if s[j] == "o":
            tmp_cand.append(j+1)
#    print(tmp_cand)
    candidate.append(tmp_cand)

for idx, ci in enumerate(candidate):
#    print(idx)
    if (len(ci) == 1) & (idx < len(candidate)-1):
        next_cand = candidate[idx+1]
#        print("ci[0]: " + str(ci[0]))
        t_n_cand = [nc_i for nc_i in next_cand if nc_i >= ci[0] + c+1]
#        print(t_n_cand)
        candidate[idx+1] = t_n_cand

for ci in candidate:
    if len(ci) == 1:
        print(ci[0])

Submission status: Time Limit Exceeded

Solution code:
import copy
N,K,C = map(int,input().split())
S = input()
tf = lambda o:1 if o=="o" else 0
yotei = [tf(i) for i in S]
ans = []

for i in range(N):
    yotei_2 = copy.deepcopy(yotei)
    yotei_2[i] = 0
    k = 0
    count = 0
    for j in range(N):
        if count > 0:
            count += 1
            if count == C+2:
                count =0
                k += 1
        if yotei_2[j] == 1 and count == 0:
            count +=1
    if count > 0:
        k += 1
    if k < K:
        ans.append(i+1)

for i in ans:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

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

wp = list(itertools.combinations(days,K))
wList =[]

for w in wp:
  w = list(w)
  isContinue = False
  for sub in range(len(w)-1):
    if w[sub+1] - w[sub] <= C:
      isContinue = True
  if isContinue == False:
    wList.append(w)

#tp = map(tuple, wList)
#qty = map(lambda x: tp.count(x), tuple(tp))
#print(set(wList[1]) & set([6]))
#print(set(wList[1] & set(6)))

ans = wList[0]
for i in wList:
  ans = (set(i) & set(list(ans)))

ans = sorted(list(ans))
for i in ans:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations

def check_must(arr, pos, k ,c):
    res = arr.copy()
    del res[pos]
    for t in combinations(res, k):
        flg = False
        for t1, t2 in zip(t[:-1], t[1:]):
            if t2 - t1 <= c:
                flg = True
                break
        if flg:
            continue
        else:
            return False, arr
    return True, arr

def main():
    n, k, c = [int(i) for i in input().split()]
    s = [1 if i is 'o' else 0 for i in input()]
    res = [i+1 for i, b in enumerate(s) if b]
    cand = []
    pos = 0
    while pos < len(res):
        flg, res = check_must(res, pos, k, c)
        if flg:
            cand.append(res[pos])
        pos+=1
    for c in cand:
        print(c)
    
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 前からと後ろからでcandに入れて両方に入るところ
N, K, C = lr()
S = sr()
cand1 = set()
cand2 = set()

def F(S):
    cand = set()
    count = 0
    cur = 0
    while cur < len(S):
        if S[cur] == 'o':
            count += 1
            cand.add(cur)
            cur += C+1            
        else:
            cur += 1
        if count >= K:
            break
    return cand

cand1 = F(S)
cand2 = F(S[::-1])
cand2 = set(N-1-x for x in cand2)
s = cand1 & cand2
s = sorted(list(s))
s = [x+1 for x in s]

def check(S):
    count = 0
    cur = 0
    while cur < len(S):
        if S[cur] == 'o':
            count += 1
            cur += C+1            
        else:
            cur += 1
        if count >= K:
            return True
    return False

for x in s:
    T = list(S)
    T[x-1] = 'x'
    if not check(T):
        print(x)

Submission status: Time Limit Exceeded

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

a = []
b = []

d = -1
for i in range(k):
    while s[d] == 'x':
        d -= 1
    b.insert(0, n+d)
    d -= c+1

d = 0
for i in range(k):
    while s[d] == 'x':
        d += 1
    if d == b[i]:
        print(d+1)
    d += c+1

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline


def inpl():
    return list(map(int, input().split()))


def GetBase(t=0):
    ret = []
    last = -C * 2 - 1
    for i, s in enumerate(S[t:]):
        if s == 'x':
            continue
        elif last + C >= i + t:
            continue

        ret.append(i + t)
        last = i + t
    return ret


def GetDepend(base_ans):
    ruiseki = []
    a = 0
    for s in S:
        if s == 'o':
            a += 1
            ruiseki.append(a)
        else:
            ruiseki.append(a)

    ret = {a: False for a in base_ans}
    for a in ret:
        if ruiseki[a] == ruiseki[min(N - 1, a + C)]:
            ret[a] = True
    return ret


def solve():
    base_ans = GetBase()
    if len(base_ans) > K:
        return []

    depend_dict = GetDepend(base_ans)
    for i, b in enumerate(base_ans):
        if depend_dict[b] is True:
            continue
        S[b] = 'x'
        tmp = GetBase(b)
        if len(tmp) + i < K:
            depend_dict[b] = True
        else:
            for s in set(tmp) - set(base_ans[i:]):
                depend_dict[s] = True

        S[b] = 'o'

    return [a + 1 for a in base_ans if depend_dict[a] is True]


N, K, C = inpl()
S = list(input().strip())

ans = solve()

for a in ans:
    print(a)

Submission status: Time Limit Exceeded

Solution code:
import copy

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

tmp = copy.deepcopy(s)
wait = 0
last_day = k
count = set()

for num, i in enumerate(tmp):
    if wait>0:
        wait -= 1
        continue
    if i == 'o':
        s[num] = 'a'
        count.add(num)
        wait = c
        last_day -= 1
        if last_day == 0:
            break

count2 = set()
last_day = k
wait = 0
for num, i in enumerate(reversed(tmp)):
    if wait>0:
        wait -= 1
        if i == 'a':
            s[num] = 'o'
        continue
    if i == 'o' or i == 'a':
        count2.add(n - num - 1)
        wait = c
        last_day -= 1
        if last_day == 0:
            break

count = count & count2
# print(count)        
ans = []    
for j in count:
    if s[j] =='o':
        continue
    wait = 0
    tmp = copy.deepcopy(s)
    last_day = k
    tmp[j] = 'x'
    for num, i in enumerate(tmp):
        if wait>0:
            if i == 'a':
                tmp[num] = 'o'
            wait -= 1
            continue
        if i == 'o' or i == 'a':
            wait = c
            last_day -= 1
            if last_day == 0:
                break
    if last_day > 0:
        ans.append(j+1)
    else:
        s = copy.deepcopy(tmp)
        
for i in ans:
    print(i)