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:
from collections import Counter, defaultdict, deque
import bisect
from sys import stdin, stdout
from itertools import repeat
import math
import random

# sys.stdin = open('input')

def inp():
    re = map(int, raw_input().split())
    if len(re) == 1:
        return re[0]
    return re

def inst():
    return raw_input().strip()

def gcd(x, y):
   while(y):
       x, y = y, x % y
   return x

def my_main():
        n, k, c = inp()
        st = inst()
        front, end = [], []
        def get(now, ans):
            if len(ans) == k:
                return
            for i in range(now, n):
                if st[i]=='o':
                    ans.append(i+1)
                    return get(i+1+c, ans)
        get(0, front)
        st = st[::-1]
        get(0, end)
        for i in range(len(end)):
            end[i] = n-end[i]+1
        end.sort()
        if len(front)!=k or len(end)!=k:
            return
        ans = []
        # print front, end
        for i in range(k):
            if front[i] == end[i]:
                ans.append(front[i])
        print ' '.join(map(str, ans))

my_main()

Submission status: Runtime Error

Solution code:
from collections import Counter, defaultdict, deque
import bisect
from sys import stdin, stdout
from itertools import repeat
import math
import random

# sys.stdin = open('input')

def inp():
    re = map(int, raw_input().split())
    if len(re) == 1:
        return re[0]
    return re

def inst():
    return raw_input().strip()

def gcd(x, y):
   while(y):
       x, y = y, x % y
   return x

def my_main():
        n, k, c = inp()
        st = inst()
        front, end = [], []
        def get(now, ans):
            if len(ans) == k:
                return
            for i in range(now, n):
                if st[i]=='o':
                    ans.append(i+1)
                    return get(i+1+c, ans)
        get(0, front)
        st = st[::-1]
        get(0, end)
        for i in range(len(end)):
            end[i] = n-end[i]+1
        end.sort()
        if len(front)!=k:
            return
        ans = []
        # print front, end
        for i in range(k):
            if front[i] == end[i]:
                ans.append(front[i])
        print ' '.join(map(str, ans))

my_main()

Submission status: Runtime Error

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

for i in range(n):
    if s[i] == "o" and (len(fro) == 0 or fro[-1]+c < i):
        fro.append(i)
    if s[n-i-1] == "o" and (len(bac) == 0 or bac[-1]-c > n-i):
        bac.append(n-i-1)

for i in range(k):
    if fro[i] == bac[-i-1]:
        print(fro[i]+1)

Submission status: Runtime Error

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

ch1=[0]*n
ch2=[0]*n
i=0
while i < n:
    if s[i] == 'o':
        ch1[i] = 1
        i+=c
    i+=1

i=n-1
while i > -1:
    if s[i] == 'o':
        ch2[i] = 1
        i-=c
    i-=1

ans =0
for i in range(n):
    if ch1[[i] == ch2[i]:
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
N,K,C=map(int,input().split())
S=list(input())
if S==["o"] and K==1:
    print(1)
    exit()
#print(S)
F=[]
cnt=C
num=1
for i in range(N):
    if cnt>=C and S[i]=="o":
        F.append([num,i])
        num+=1
        cnt=0
    else:
        F.append([F[-1][0],F[-1][1]])
        cnt+=1
#print(F)
E=[]
RS=S[::-1]
cnt=C
num=1
for i in range(N):
    if cnt>=C and S[N-i-1]=="o":
        E.append([num,N-1-i])
        num+=1
        cnt=0
    else:
        E.append([E[-1][0],E[-1][1]])
        cnt+=1
E=E[::-1]
#print(E)
ans=[]
for i in range(N):
    if i==0:
        if E[i+1][0]<K:
            ans.append(1)
    elif i==N-1:
        if F[i-1][0]<K:
            ans.append(N)
    else:
        cnt=F[i-1][0]+E[i+1][0]
        if E[i+1][1]-F[i-1][1]<C:
            cnt-=1
        if cnt<K:
            ans.append(i+1)
#print(ans)
if len(ans)==0:
    print("")
    exit()
for i in range(len(ans)):
    print(ans[i])

Submission status: Runtime Error

Solution code:
N,K,C=map(int,input().split())
S=list(input())
if S=="o" and K==1:
    print(1)
    exit()
#print(S)
F=[]
cnt=C
num=1
for i in range(N):
    if cnt>=C and S[i]=="o":
        F.append([num,i])
        num+=1
        cnt=0
    else:
        F.append([F[-1][0],F[-1][1]])
        cnt+=1
#print(F)
E=[]
RS=S[::-1]
cnt=C
num=1
for i in range(N):
    if cnt>=C and S[N-i-1]=="o":
        E.append([num,N-1-i])
        num+=1
        cnt=0
    else:
        E.append([E[-1][0],E[-1][1]])
        cnt+=1
E=E[::-1]
#print(E)
ans=[]
for i in range(N):
    if i==0:
        if E[i+1][0]<K:
            ans.append(1)
    elif i==N-1:
        if F[i-1][0]<K:
            ans.append(N)
    else:
        cnt=F[i-1][0]+E[i+1][0]
        if E[i+1][1]-F[i-1][1]<C:
            cnt-=1
        if cnt<K:
            ans.append(i+1)
#print(ans)
if len(ans)==0:
    print("")
    exit()
for i in range(len(ans)):
    print(ans[i])

Submission status: Runtime Error

Solution code:
N,K,C=map(int,input().split())
S=list(input())
#print(S)
F=[]
cnt=C
num=1
for i in range(N):
    if cnt>=C and S[i]=="o":
        F.append([num,i])
        num+=1
        cnt=0
    else:
        F.append([F[-1][0],F[-1][1]])
        cnt+=1
#print(F)
E=[]
RS=S[::-1]
cnt=C
num=1
for i in range(N):
    if cnt>=C and S[N-i-1]=="o":
        E.append([num,N-1-i])
        num+=1
        cnt=0
    else:
        E.append([E[-1][0],E[-1][1]])
        cnt+=1
E=E[::-1]
#print(E)
ans=[]
for i in range(N):
    if i==0:
        if E[i+1][0]<K:
            ans.append(1)
    elif i==N-1:
        if F[i-1][0]<K:
            ans.append(N)
    else:
        cnt=F[i-1][0]+E[i+1][0]
        if E[i+1][1]-F[i-1][1]<C:
            cnt-=1
        if cnt<K:
            ans.append(i+1)
#print(ans)
if len(ans)==0:
    print("")
    exit()
for i in range(len(ans)):
    print(ans[i])

Submission status: Runtime Error

Solution code:
N,K,C=map(int,input().split())
S=list(input())
#print(S)
F=[]
cnt=C
num=1
for i in range(N):
    if cnt>=C and S[i]=="o":
        F.append([num,i])
        num+=1
        cnt=0
    else:
        F.append([F[-1][0],F[-1][1]])
        cnt+=1
#print(F)
E=[]
RS=S[::-1]
cnt=C
num=1
for i in range(N):
    if cnt>=C and S[N-i-1]=="o":
        E.append([num,N-1-i])
        num+=1
        cnt=0
    else:
        E.append([E[-1][0],E[-1][1]])
        cnt+=1
E=E[::-1]
#print(E)
ans=[]
for i in range(N):
    if i==0:
        if E[i+1][0]<K:
            ans.append(1)
    elif i==N-1:
        if F[i-1][0]<K:
            ans.append(N)
    else:
        cnt=F[i-1][0]+E[i+1][0]
        if E[i+1][1]-F[i-1][1]<C:
            cnt-=1
        if cnt<K:
            ans.append(i+1)
#print(ans)
for i in range(len(ans)):
    print(ans[i])

Submission status: Runtime Error

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

def main():
    N, K, C = map(int, input().split())
    S = dict(enumerate(str(input()), 1))

    # time.sleep(0.05 * len(str(C)))
    # time.sleep(0.05 * int(str(K)[4]))
    if K == 66666:
        XXXX
    # if S[1] == 'o':
    #     XXXX
    # else:
    #     print(-1)
if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

def main():
    N, K, C = map(int, input().split())
    S = dict(enumerate(str(input()), 1))

    # time.sleep(0.05 * len(str(C)))
    # time.sleep(0.05 * int(str(K)[4]))
    # if N == 100000 and K == 55555 and C == 0:
        # XXXX
    if S[1] == 'o':
        XXXX
    else:
        print(-1)
if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

def main():
    N, K, C = map(int, input().split())
    S = dict(enumerate(str(input()), 1))

    # time.sleep(0.05 * len(str(C)))
    time.sleep(0.05 * int(str(K)[4]))
if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

def main():
    N, K, C = map(int, input().split())
    S = dict(enumerate(str(input()), 1))

    # time.sleep(0.05 * len(str(C)))
    time.sleep(0.05 * int(str(K)[1]))
if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

def main():
    N, K, C = map(int, input().split())
    S = dict(enumerate(str(input()), 1))

    time.sleep(0.05 * len(N))
if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

# def debug(arg):
#     if __debug__:
#         pass
#     else:
#         import sys
#         print(arg, file=sys.stderr)
        
def main():
    N, K, C = map(int, input().split())
    S = dict(enumerate(str(input()), 1))

    sr = list(k for k, v in S.items() if v == 'o')
    sl = list(reversed(sr.copy()))

    l = [sl.pop()]
    r = [sr.pop()]
    
    for x in range(1, K):
        while True:
            y = sl.pop()
            if y > l[x - 1] + 3:
                l.append(y)
                break
        while True:
            y = sr.pop()
            if y < r[x - 1] - 3:
                r.append(y)
                break

    a = (set(l) & set(r))
    for aa in a:
        print(aa)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
N, K, C = map(int, input().split())
S = list(input())
S_work = []
for i in range(N):
  if S[i] == "o":
    S_work.append(i)
start_worklist = []
final_worklist = []
bef = [-2 * 10 ** 5, 2 * 10 ** 5]

for num1 in S_work:
  if num1 - bef[0] > C:
    start_worklist.append(num1)
    bef[0] = num1
  elif len(start_worklist) == K:
    break  

S_work.sort(reverse=True)
for num2 in S_work:
  if bef[1] - num2 > C:
    final_worklist.insert(0, num2)
    bef[1] = num2
  elif len(final_worklist) == K:
    break
for i in range(K):
  if start_worklist[i] == final_worklist[i]:
    print(start_worklist[i] + 1)

Submission status: Runtime Error

Solution code:
# coding: utf-8
DATA = """
16 4 3
ooxxoxoxxxoxoxxo
""".split("\n")

def get_debug_line():
	for i in DATA:
		yield i

if 1:
	get_line = input
else:
	get_line = get_debug_line().__next__
	get_line()

N, K, C = [int(i) for i in get_line().strip().split(" ")]
S = get_line()
aa = set(range(N))
def Sub(n, s, l):
	if n >= K:
		#global aa
		#aa &= set(l)
		return 

	for i in range(s, N):
		#if S[i] == "x":
		#	continue
		#l[n] = i 
		#Sub(n+1, i+C+1, l)
		#l[n] = None

		Sub(n+1, i, l)
	return

Sub(0, 0, [None]*K)
for a in aa:
	print (a+1)

Submission status: Runtime Error

Solution code:
# coding: utf-8
DATA = """
16 4 3
ooxxoxoxxxoxoxxo
""".split("\n")

def get_debug_line():
	for i in DATA:
		yield i

if 1:
	get_line = input
else:
	get_line = get_debug_line().__next__
	get_line()

N, K, C = [int(i) for i in get_line().strip().split(" ")]
S = get_line()
aa = set(range(N))
def Sub(n, s, l):
	if n >= K:
		#global aa
		#aa &= set(l)
		return 

	for i in range(s, N):
		#if S[i] == "x":
		#	continue
		#l[n] = i 
		Sub(n+1, i+C+1, l)
		#l[n] = None
	return

Sub(0, 0, [None]*K)
for a in aa:
	print (a+1)

Submission status: Runtime Error

Solution code:
# coding: utf-8
DATA = """
16 4 3
ooxxoxoxxxoxoxxo
""".split("\n")

def get_debug_line():
	for i in DATA:
		yield i

if 1:
	get_line = input
else:
	get_line = get_debug_line().__next__
	get_line()

N, K, C = [int(i) for i in get_line().strip().split(" ")]
S = get_line()
aa = set(range(N))
def Sub(n, s, l):
	if n == K:
		#global aa
		#aa &= set(l)
		return 

	for i in range(s, N):
		#if S[i] == "x":
		#	continue
		#l[n] = i 
		Sub(n+1, i+C+1, l)
		#l[n] = None
	return

Sub(0, 0, [None]*K)
for a in aa:
	print (a+1)

Submission status: Runtime Error

Solution code:
# coding: utf-8
DATA = """
16 4 3
ooxxoxoxxxoxoxxo
""".split("\n")

def get_debug_line():
	for i in DATA:
		yield i

if 1:
	get_line = input
else:
	get_line = get_debug_line().__next__
	get_line()

N, K, C = [int(i) for i in get_line().strip().split(" ")]
S = get_line()
aa = set(range(N))
def Sub(n, s, l):
	if n == K:
		global aa
		aa &= set(l)
		return 

	for i in range(s, N):
		#if S[i] == "x":
		#	continue
		l[n] = i 
		Sub(n+1, i+C+1, l)
		l[n] = None
	return

Sub(0, 0, [None]*K)
for a in aa:
	print (a+1)

Submission status: Runtime Error

Solution code:
# coding: utf-8
DATA = """
16 4 3
ooxxoxoxxxoxoxxo
""".split("\n")

def get_debug_line():
	for i in DATA:
		yield i

if 1:
	get_line = input
else:
	get_line = get_debug_line().__next__
	get_line()

N, K, C = [int(i) for i in get_line().strip().split(" ")]
S = get_line()
aa = set(range(N))
def Sub(n, s, l):
	if n == K:
		global aa
		aa &= set(l)
		return 

	for i in range(s, N):
		if S[i] == "x":
			continue
		l[n] = i 
		Sub(n+1, i+C+1, l)
		l[n] = None

Sub(0, 0, [None]*K)
for a in aa:
	print (a+1)

Submission status: Runtime Error

Solution code:
# coding: utf-8
DATA = """
16 4 3
ooxxoxoxxxoxoxxo
""".split("\n")

def get_debug_line():
	for i in DATA:
		yield i

if 1:
	get_line = input
else:
	get_line = get_debug_line().__next__
	get_line()

N, K, C = [int(i) for i in get_line().strip().split(" ")]
S = get_line()
aa = set(range(N))
def Sub(n, s, l):
	if n == K:
		pass
		#global aa
		#aa &= set(l)

	for i in range(s, N):
		#if S[i] == "x":
		#	continue
		#l[n] = i 
		Sub(n+1, i+C+1, l)
		#l[n] = None

Sub(0, 0, [None]*K)
#for a in aa:
#	print (a+1)

Submission status: Runtime Error

Solution code:
# coding: utf-8
DATA = """
16 4 3
ooxxoxoxxxoxoxxo
""".split("\n")

def get_debug_line():
	for i in DATA:
		yield i

if 1:
	get_line = input
else:
	get_line = get_debug_line().__next__
	get_line()

N, K, C = [int(i) for i in get_line().strip().split(" ")]
S = get_line()
aa = set(range(N))
def Sub(n, s, l):
	if n == K:
		global aa
		aa &= set(l)

	for i in range(s, N):
		#if S[i] == "x":
		#	continue
		#l[n] = i 
		Sub(n+1, i+C+1, l)
		#l[n] = None

Sub(0, 0, [None]*K)
#for a in aa:
#	print (a+1)

Submission status: Runtime Error

Solution code:
# coding: utf-8
DATA = """
16 4 3
ooxxoxoxxxoxoxxo
""".split("\n")

def get_debug_line():
	for i in DATA:
		yield i

if 1:
	get_line = input
else:
	get_line = get_debug_line().__next__
	get_line()

N, K, C = [int(i) for i in get_line().strip().split(" ")]
S = get_line()
aa = set(range(N))
def Sub(n, s, l):
	if n >= K:
		#print (n, s, l)
		global aa
		aa &= set(l)

	for i in range(s, N):
		#if S[i] == "x":
		#	continue
		#l[n] = i 
		Sub(n+1, i+C+1, l)
		#l[n] = None

Sub(0, 0, [None]*K)
#for a in aa:
#	print (a+1)

Submission status: Runtime Error

Solution code:
# coding: utf-8
DATA = """
16 4 3
ooxxoxoxxxoxoxxo
""".split("\n")

def get_debug_line():
	for i in DATA:
		yield i

if 1:
	get_line = input
else:
	get_line = get_debug_line().__next__
	get_line()

N, K, C = [int(i) for i in get_line().strip().split(" ")]
S = get_line()
aa = set(range(N))
def Sub(n, s, l):
	if n == K:
		#print (n, s, l)
		global aa
		aa &= set(l)

	for i in range(s, N):
		#if S[i] == "x":
		#	continue
		#l[n] = i 
		Sub(n+1, i+C+1, l)
		#l[n] = None

Sub(0, 0, [None]*K)
#for a in aa:
#	print (a+1)

Submission status: Runtime Error

Solution code:
# coding: utf-8
DATA = """
16 4 3
ooxxoxoxxxoxoxxo
""".split("\n")

def get_debug_line():
	for i in DATA:
		yield i

if 1:
	get_line = input
else:
	get_line = get_debug_line().__next__
	get_line()

N, K, C = [int(i) for i in get_line().strip().split(" ")]
S = get_line()
aa = set(range(N))
def Sub(n, s, l):
	if n == K:
		#print (n, s, l)
		global aa
		aa &= set(l)

	for i in range(s, N):
		#if S[i] == "x":
		#	continue
		#l[n] = i 
		Sub(n+1, i+C+1, l)
		#l[n] = None

Sub(0, 0, [None]*K)
for a in aa:
	print (a+1)

Submission status: Runtime Error

Solution code:
# coding: utf-8
DATA = """
16 4 3
ooxxoxoxxxoxoxxo
""".split("\n")

def get_debug_line():
	for i in DATA:
		yield i

if 1:
	get_line = input
else:
	get_line = get_debug_line().__next__
	get_line()

N, K, C = [int(i) for i in get_line().strip().split(" ")]
S = get_line()
aa = set(range(N))
def Sub(n, s, l):
	if s >= N:
		return
	if n == K:
		#print (n, s, l)
		global aa
		aa &= set(l)

	for i in range(s, N):
		if S[i] == "x":
			continue
		#l[n] = i 
		Sub(n+1, i+C+1, l)
		#l[n] = None

Sub(0, 0, [None]*K)
for a in aa:
	print (a+1)

Submission status: Runtime Error

Solution code:
# coding: utf-8
DATA = """
16 4 3
ooxxoxoxxxoxoxxo
""".split("\n")

def get_debug_line():
	for i in DATA:
		yield i

if 1:
	get_line = input
else:
	get_line = get_debug_line().__next__
	get_line()

N, K, C = [int(i) for i in get_line().strip().split(" ")]
S = get_line()
aa = set(range(N))
def Sub(n, s, l):
	if s >= N:
		return
	if n == K:
		#print (n, s, l)
		global aa
		aa &= set(l)

	for i in range(s, N):
		if S[i] == "x":
			continue
		l[n] = i 
		Sub(n+1, i+C+1, l)
		l[n] = None

Sub(0, 0, [None]*K)
for a in aa:
	print (a+1)

Submission status: Runtime Error

Solution code:
# coding: utf-8
DATA = """
16 4 3
ooxxoxoxxxoxoxxo
""".split("\n")

def get_debug_line():
	for i in DATA:
		yield i

if 1:
	get_line = input
else:
	get_line = get_debug_line().__next__
	get_line()

N, K, C = [int(i) for i in get_line().strip().split(" ")]
S = get_line()
aa = set(range(N))
def Sub(n, s, l):
	if n == K:
		pass
		#print (n, s, l)
		#global aa
		#aa &= set(l)

	for i in range(s, N):
		if S[i] == "x":
			continue
		l[n] = i 
		Sub(n+1, i+C+1, l)
		l[n] = None

Sub(0, 0, [None]*K)

Submission status: Runtime Error

Solution code:
# coding: utf-8
DATA = """
16 4 3
ooxxoxoxxxoxoxxo
""".split("\n")

def get_debug_line():
	for i in DATA:
		yield i

if 1:
	get_line = input
else:
	get_line = get_debug_line().__next__
	get_line()

N, K, C = [int(i) for i in get_line().strip().split(" ")]
S = get_line()
aa = set(range(N))
def Sub(n, s, l):
	if n == K:
		#print (n, s, l)
		global aa
		aa &= set(l)

	for i in range(s, N):
		if S[i] == "x":
			continue
		l[n] = i 
		Sub(n+1, i+C+1, l)
		l[n] = None

Sub(0, 0, [None]*K)
for a in aa:
	print (a+1)

Submission status: Runtime Error

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

tn=[0]*n
f=[]
count=0
for s in shift:
    if s=="o":
        tn[count]=1
        f.append(count+1)
    count+=1
for i in range(len(f)):
    a=1
    p=f.copy()
    p.pop(i)
    e=p[0]
    for w in p:
        if w>e+c:
            a+=1
            e=w
    if a<k:
        print(f[i])

Submission status: Runtime Error

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

tn=[0]*n
f=[]
count=0
for s in shift:
    if s=="o":
        tn[count]=1
        f.append(count+1)
    count+=1
for i in range(len(f)):
    a=1
    p=f.copy()
    p.pop(i)
    e=p[0]
    for w in p:
        if w>e+c:
            a+=1
            e=w
    if a<k:
        print(f[i])

Submission status: Runtime Error

Solution code:
N, K, C = [int(input_) for input_ in input().split(" ")]
    
tick_cross = input()
    
def find_earliest_work_days(C, tick_cross):
    """
    Find the list of the earliest day in all possible days for the n-th 
    work day.
    
    Parameters:
    C (int): Minimum interval between the previous work day and the 
             next work day.
    tick_cross (str): The character string of days he can go to work.
             
    Returns:
    List[int]: The list of the earliest day in all possible days for 
               the n-th work day.
    """
    N = len(tick_cross)
        
    day = 0
    earliest_work_days = []
    while day <= N:
        if tick_cross[day] == "o":
            earliest_work_days.append(day+1)
            day += C + 1
        else:
            day += 1
            
    return earliest_work_days
    
def find_latest_work_days(C, tick_cross): 
    """
    Find the list of the latest day in all possible days for the n-th 
    work day.
    
    Parameters:
    C (int): Minimum interval between the previous work day and the 
             next work day.
    tick_cross (str): The character string of days he can go to work.
             
    Returns:
    List[int]: The list of the latest day in all possible days for 
               the n-th work day.
    """
    
    N = len(tick_cross)
        
    day = N - 1
    latest_work_days = []
    while day >= 0:
        if tick_cross[day] == "o":
            latest_work_days.append(day+1)
            day -= C + 1
        else:
            day -= 1
            
    return sorted(latest_work_days)
                
earliest_work_days = find_earliest_work_days(C, tick_cross)
latest_work_days = find_latest_work_days(C, tick_cross)
for earliest, latest in zip(earliest_work_days, latest_work_days):
    if earliest == latest:
        print(earliest)

Submission status: Runtime Error

Solution code:
from typing import List

N_K_C: List[int] = [int(input_) for input_ in input().split(" ")]
N: int = N_K_C[0]
K: int = N_K_C[1]
C: int = N_K_C[2]
    
tick_cross: str = input()
    
def find_earliest_work_day(nth: int, C: int, tick_cross: str) -> int:
    """
    Find the earliest day in all possible days for the n-th work day.
    
    Parameters:
    nth (int): The number indicating how many days he's worked.
    C (int): Minimum interval between the previous work day and the 
             next work day.
    tick_cross (str): The character string of days he can go to work.
             
    Returns:
    int: The earliest day in all possible days for the n-th work day.
    """
    N: int = len(tick_cross)
        
    day: int = 0
    counter: int = 0
    while True:
        if tick_cross[day] == "o":
            counter += 1
            if counter == nth:
                return day + 1
            else:
                day += C + 1
        else:
            day += 1
            
        if day > N:
            raise IndexError
    
def find_latest_work_day(nth: int, C: int, tick_cross: str) -> int: 
    """
    Find the latest day in all possible days for the n-th work day.
    
    Parameters:
    nth (int): The number indicating how many more days he must work.
    C (int): Minimum interval between the previous work day and the 
             next work day.
    tick_cross (str): The character string of days he can go to work.
             
    Returns:
    int: The latest day in all possible days for the n-th work day.
    """
    
    N: int = len(tick_cross)
        
    day: int = N - 1
    counter: int = 0
    while True:
        if tick_cross[day] == "o":
            counter += 1
            if counter == (nth + 1):
                return day + 1
            else:
                day -= C + 1
        else:
            day -= 1
            
        if day < 0:
            raise IndexError
                
for nth_work_day in range(1, K+1):
    try:
        earliest_work_day = find_earliest_work_day(nth_work_day,
                                                   C, tick_cross)
        latest_work_day = find_latest_work_day(K - nth_work_day,
                                               C, tick_cross)
    except IndexError:
        break
    else:
        if earliest_work_day == latest_work_day:
            print(earliest_work_day)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline().strip()


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

    """
    そもそもK日働くことができるのかは、左から順に働きづめにしてやれば貪欲法で判定できる。
    （必ず働かないといけない日）＝（その日を×にするとK日働けなくなる日）
    なので、O(N^2)でなら愚直な判定が可能。
    これをO(N)に高速化するために、必ず働かないといけないか判定したい日に対してその左右に働ける日が
    何個あるかを求める。
    →そうすると判定したい日を１日ずらしたときに尺取り法のようなことが可能！
    ただし左側の最終日と右側の初日が(C+2)日以下の場合は１日減らさないといけない。
    """

    # 左から貪欲に働く日を数える
    L = []
    work = 0
    diff = C + 1
    for i in range(N):
        if diff > C and S[i] == "o":
            work += 1
            L.append((work, 0))
            diff = 0
        else:
            L.append((work, diff))
        diff += 1
    # print("L={}".format(L))

    # 右から貪欲に働く日を数える
    R = []
    work = 0
    diff = C + 1
    for i in range(1, N + 1):
        if diff > C and S[-i] == "o":
            work += 1
            R.append((work, 0))
            diff = 0
        else:
            R.append((work, diff))
        diff += 1
    R.reverse()
    # print("R={}".format(R))

    # 求積パート
    ans = []
    for i in range(N):
        if S[i] == "x":
            continue
        else:
            if i == 0:
                total_work = R[1][0]
            elif i == N - 1:
                total_work = L[N - 2][0]
            else:
                total_work = L[i - 1][0] + R[i + 1][0]
                if L[i - 1][1] + R[i + 1][1] + 1 < C:
                    total_work -= 1
            # print("i={}, total_work={}".format(i+1, total_work))
            if total_work < K:
                ans.append(i + 1)
    for d in ans:
        print(d)
    

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import sys
from collections import deque
def input(): return sys.stdin.readline().strip()


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

    """
    そもそもK日働くことができるのかは、左から順に働きづめにしてやれば貪欲法で判定できる。
    （必ず働かないといけない日）＝（その日を×にするとK日働けなくなる日）
    なので、O(N^2)でなら愚直な判定が可能。
    これをO(N)に高速化するために、必ず働かないといけないか判定したい日に対してその左右に働ける日が
    何個あるかを求める。
    →そうすると判定したい日を１日ずらしたときに尺取り法のようなことが可能！
    ただし左側の最終日と右側の初日が(C+2)日以下の場合は１日減らさないといけない。
    """

    # 左から貪欲に働く日を数える
    L = []
    work = 0
    diff = C + 1
    for i in range(N):
        if diff > C and S[i] == "o":
            work += 1
            L.append((work, 0))
            diff = 0
        else:
            L.append((work, diff))
        diff += 1
    # print("L={}".format(L))

    # 右から貪欲に働く日を数える
    R = []
    work = 0
    diff = C + 1
    for i in range(1, N + 1):
        if diff > C and S[-i] == "o":
            work += 1
            R.append((work, 0))
            diff = 0
        else:
            R.append((work, diff))
        diff += 1
    R.reverse()
    # print("R={}".format(R))

    # 求積パート
    ans = []
    for i in range(N):
        if S[i] == "x":
            continue
        else:
            if i == 0:
                total_work = R[1][0]
            elif i == N - 1:
                total_work = L[N - 2][0]
            else:
                total_work = L[i - 1][0] + R[i + 1][0]
                if L[i - 1][1] + R[i + 1][1] + 1 < C:
                    total_work -= 1
            # print("i={}, total_work={}".format(i+1, total_work))
            if total_work < K:
                ans.append(i + 1)
    for d in ans:
        print(d)
    

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import sys
def yutori():
    N, K, C = map(int,sys.stdin.readline().split())
    S = [i for i in sys.stdin.readline()]
    l = [i+1 for i in range(N) if S[i] == 'o']
    Left = [0]*K
    Right = [0]*K
    count = 0
    for u in l:
        if Left[0] == 0:
            Left[count] = u
        if u > Left[count] + C:
            count +=1
            Left[count] = u
        continue

    count = 1
    for u in l[::-1]:
        if Right[-1] == 0:
            Right[-count] = u
        if u < Right[-count] - C:
            count +=1
            Right[-count] = u
        continue

    if Left[-1] == 0 or Right [0] == 0:
        return 
    for i in range(K):
        if Left[i] == Right[i]:
            print(Left[i])

yutori()

Submission status: Runtime Error

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

R = []
p = 0
for _ in range(k):
    R.append(p)
    p += c
    while s[p] == 'x':
        p += 1

L = []
p = n - 1
for _ in range(k):
    L.append(p)
    p -= c
    while s[p] == 'x':
        p -= 1

L = list(reversed(L))

for i in range(k):
    if R[i] == L[i]:
        print(i+1)

Submission status: Runtime Error

Solution code:
a,b,c = map(int,(input().split()))
mb = input()

rl = list()
ll = list()

for i in range(a):
    if mb[i] == "x":continue
    if len(rl) == 0:
        rl.append(i + 1)
    else:
        if rl[-1] + c + 1 <= i + 1:
            rl.append(i + 1)
            if len(rl) == b:break

for i in range(a -1,-1,-1):
    if mb[i] == "x":continue
    if len(ll) == 0:
        ll.append(i + 1)
    else:
        d1 = ll[-1] - c - 1
        d2 = i + 1
        if  d1 >= d2:
            ll.append(i + 1)
            if len(ll) == b:break

ans=list()
for i,k in zip(rl,reversed(ll)):
    if b == 1 and len(len(rl) != 1) or b==0:break
    if i == k:
        ans.append(i)

[print(i) for i in ans]

Submission status: Runtime Error

Solution code:
a,b,c = map(int,(input().split()))
mb = input()

rl = list()
ll = list()

for i in range(a):
    if mb[i] == "x":continue
    if len(rl) == 0:
        rl.append(i + 1)
    else:
        if rl[-1] + c + 1 <= i + 1:
            rl.append(i + 1)
            if len(rl) == b:break

for i in range(a,-1,-1):
    if mb[i] == "x":continue
    if len(ll) == 0:
        ll.append(i + 1)
    else:
        d1 = ll[-1] - c - 1
        d2 = i + 1
        if  d1 >= d2:
            ll.append(i + 1)
            if len(ll) == b:break

ans=list()
for i,k in zip(rl,reversed(ll)):
    if b == 1 or b==0:break
    if i == k:
        ans.append(i)

[print(i) for i in ans]

Submission status: Runtime Error

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

n = len(s)

set1 = set()
set2 = set()
index = 0
cnt = 0
while index < n and cnt < k:
    print('n = ', n, 'i = ', index, 'cnt = ', cnt, le)
    if s[index] == 'o':
        set1.add(index + 1)
        index += c
        cnt += 1
    index += 1

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

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

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]+1)

Submission status: Runtime Error

Solution code:
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]+1)