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: Wrong Answer

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

right, left = [0 for _ in range(N)], [0 for _ in range(N)]

cnt = 0
work = 0
while True:
    if work == K:
        break
    if S[cnt] != "x":
        right[cnt] += 1
        work += 1
        cnt += C+1
    else:
        cnt += 1

S = list(reversed(S))

cnt = 0
work = 0
while True:
    if work == K:
        break
    if S[cnt] != "x":
        left[cnt] += 1
        work += 1
        cnt += C+1
    else:
        cnt += 1

left.reverse()

for i in range(N):
    if right[i] == left[i] == 1:
        print(i+1)

Submission status: Wrong Answer

Solution code:
import itertools
# 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:
    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:
    if S[i] == 'o':
        if len(L) == 0:
            L.append(i)
        elif L[-1] - C > i:
            L.append(i)
    i -= 1

ans = [i + 1 for i in set(F) & set(L)]
if len(ans) != 0:
    ans.sort()
    [print(i) for i in ans]

Submission status: Wrong Answer

Solution code:
import itertools
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:
    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:
    if S[i] == 'o':
        if len(L) == 0:
            L.append(i)
        elif L[-1] - C > i:
            L.append(i)
    i -= 1

ans = [i + 1 for i in set(F) & set(L)]
ans.sort()
[print(i) for i in ans]

Submission status: Wrong Answer

Solution code:
import itertools
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:
    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:
    if S[i] == 'o':
        if len(L) == 0:
            L.append(i)
        elif L[-1] - C > i:
            L.append(i)
    i -= 1

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8

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

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: Wrong Answer

Solution code:
import sys

N, K, C = map(int, sys.stdin.readline().rstrip().split())
S = sys.stdin.readline().rstrip()

L = [0] * K

k = 0
i = 0
while i < N:
    if S[i] == 'o':
        L[k] = i + 1
        k += 1
        if k == K:
            break
        i += (C + 1)
    else:
        i += 1

if k < K:
    sys.exit()

k = 0
i = N - 1
while i > -1:
    if S[i] == 'o':
        if i + 1 in L:
            print(i + 1)
        k += 1
        if k == K:
            break
        i -= (C + 1)
    else:
        i -= 1

Submission status: Wrong Answer

Solution code:
import sys

N, K, C = map(int, sys.stdin.readline().rstrip().split())
S = sys.stdin.readline().rstrip()

L = [0] * K

k = 0
i = 0
while i < N:
    if S[i] == 'o':
        L[k] = i + 1
        k += 1
        if k == K:
            break
        i += (C + 1)
    else:
        i += 1

k = 0
i = N - 1
while i > -1:
    if S[i] == 'o':
        if i + 1 in L:
            print(i + 1)
        k += 1
        if k == K:
            break
        i -= (C + 1)
    else:
        i -= 1

Submission status: Wrong Answer

Solution code:
N, K, C = map(int, input().split())
S = input()
S_reverse = S[::-1]

l = []
r = []

i = 0
while i<N and len(l)<K:
    if S[i] == 'o':
        l.append(i+1)
        i += C+1
    else:
        i += 1

i = 0
while i<N and len(r)<K:
    if S_reverse[i] == 'o':
        r.append(i)
        i += C+1
    else:
        i += 1

r = [N - i for i in r]

ans = set(l) & set(r)

ans = list(ans)
ans.sort()

for i in ans:
    print(i)

Submission status: Wrong Answer

Solution code:
import sys

N, K, C = map(int, sys.stdin.readline().rstrip().split())
S = sys.stdin.readline().rstrip()

L = [0] * K

k = 0
i = 0
while i < N:
    if S[i] == 'o':
        L[k] = i + 1
        k += 1
        if k == K:
            break
        i += (C + 1)
    else:
        i += 1
k = 0
i = N - 1
while i > 0:
    if S[i] == 'o':
        if i + 1 in L:
            print(i + 1)
        k += 1
        if k == K:
            break
        i -= (C + 1)
    else:
        i -= 1

Submission status: Wrong Answer

Solution code:
import sys

N, K, C = map(int, sys.stdin.readline().rstrip().split())
S = sys.stdin.readline().rstrip()

L = [0] * K

h = 0
k = 0
i = 0
while i < N:
    if S[i] == 'o':
        L[k] = i + 1
        k += 1
        if k == K:
            break
        i += C
    else:
        i += 1

h = 0
k = 0
i = N - 1
while i > 0:
    if S[i] == 'o':
        if i + 1 in L:
            print(i + 1)
        k += 1
        if k == K:
            break
        i -= (C + 1)
    else:
        i -= 1

Submission status: Wrong Answer

Solution code:
import sys

N, K, C = map(int, sys.stdin.readline().rstrip().split())
S = sys.stdin.readline().rstrip()

L = [0] * K
R = [0] * K

h = 0
k = 0
for i in range(N):
    if h > 0:
        h -= 1
        continue
    if S[i] == 'o':
        L[k] = i + 1
        k += 1
        if k == K:
            break
        h = C

h = 0
k = 0
ans = []
for i in reversed(range(N)):
    if h > 0:
        h -= 1
        continue
    if S[i] == 'o':
        R[k] = i + 1
        if i + 1 in L:
            ans.append(str(i + 1))
        k += 1
        if k == K:
            break
        h = C

if len(ans) > 0:
    print('\n'.join(ans))

Submission status: Wrong Answer

Solution code:
"""
import sys
sys.setrecursionlimit(200000)

[n,k,c] = [int(i) for i in input().split()]
s = input()
s.replace("o","1")
s.replace("x","0")
def bun(k_day,s_ox,c_day):
    if k_day = 0:
        return
    else:
        for i in range(len(s_ox)):
            if s_ox[i] == "1":

                bun(k_day-1,s_ox[i + c_day:],c_day)

        return

"""


l = []
r = []
[n,k,c] = [int(i) for i in input().split()]
s = input()

if c != 0:
    i = 0
    while i < n:
        if s[i] == "o":
            l.append(i)
            i += c
        i += 1
    i = 1
    while i <= n:
        if s[n-i] == "o":
            r.append(n - i)
            i += c
        i += 1
    ans = []
    r.sort()
    for i in range(len(l)):
        if l[i] == r[i]:
            ans.append(l[i])
    print(l,r)
    for i in range(len(ans)):
        print(ans[i]+1)
else:
    print()

Submission status: Wrong Answer

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

now = 0
cnt = 0
L = [0] * (K + 1)
while now < N:
    if S[now] == 'x':
        now += 1
        continue
    cnt = min(K, cnt + 1)
    L[cnt] = now
    now += C + 1

now = N - 1
cnt = K
R = [0] * (K + 1)
while now >= 0:
    if S[now] == 'x':
        now -= 1
        continue
    cnt = max(0, cnt - 1)
    R[cnt] = now
    now -= C + 1

ans = []
for i, (l, r) in enumerate(zip(L[1:], R), start=1):
    if l == r and S[l] == 'o':
        ans.append(l + 1)
print(*ans, sep='\n')

Submission status: Wrong Answer

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

now = 0
cnt = 0
L = [0] * (K + 1)
while now < N:
    if S[now] == 'x':
        now += 1
        continue
    cnt = min(K, cnt + 1)
    L[cnt] = now
    now += C + 1

now = N - 1
cnt = K
R = [0] * (K + 1)
while now >= 0:
    if S[now] == 'x':
        now -= 1
        continue
    cnt = max(0, cnt - 1)
    R[cnt] = now
    now -= C + 1

ans = []
for i, (l, r) in enumerate(zip(L[1:], R), start=1):
    if l == r:
        ans.append(l + 1)
print(*ans, sep='\n')

Submission status: Wrong Answer

Solution code:
def getWorkDay(S,N,C,K):
    cnt = 0
    day = 0
    flag = False
    L = [0] * N
    for i in range(N):
        if cnt >= K:
            break
        if flag:
            day += 1
            if S[i] == 'o' and day > C:
                cnt += 1
                L[i] = cnt
                day = 0
        else:
            if S[i] == 'o' and day == 0:
                cnt += 1
                L[i] = cnt
                day = 0
                flag = True
    return L

def main():
    N, K, C = map(int, input().split())
    S = list(input())
    L = getWorkDay(S,N,C,K)
    S.reverse()
    R = getWorkDay(S,N,C,K)
    R.reverse()

    for i in range(N):
        if L[i] and R[i]:
            print(i+1)



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)

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

    cuml = [0] * (n + 1)
    cumr = [0] * (n + 1)
    idx = []

    for i in range(n):
        if s[i] == 'o':
            idx.append(i)
            cuml[i + 1] = cuml[max(i - c,0)] + 1
        else:
            cuml[i + 1] = cuml[i]
    
    for i in range(n - 1,-1,-1):
        if s[i] == 'o':
            cumr[i] = cumr[min(i + c + 1,n)] + 1
        else:
            cumr[i] = cumr[i + 1]
    
    ans = []
    #print(idx,cuml,cumr)
    for i in idx:
        flag = False
        if cuml[i] >= k or cumr[i + 1] >= k:
            continue

        for j in range(i - c,i):
            if cuml[max(j + 1,0)] + cumr[min(j + c + 1,n)] >= k:
                flag = True
                break

        if flag:
            continue
        else:
            ans.append(i + 1)
    
    for i in range(len(ans)):
        print(ans[i])
 
if __name__ =='__main__':
    main()

Submission status: Wrong Answer

Solution code:
import collections as c

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


A = sorted(L+R)

ans = []
for i in range(len(A)-1):
	if A[i] == A[i+1]:
		ans.append(A[i])

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

Submission status: Wrong Answer

Solution code:
import collections as c

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


R = R[::-1]

l = 0
r = 0

ans = []
while l < len(L):
	if L[l] == R[r]:
		ans.append(L[l])
		l += 1
		r += 1

	elif L[l] < R[r]:
		l += 1
	else:
		r += 1

	if r == len(R):
		break

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

Submission status: Wrong Answer

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

reversed(R)
for l,r in zip(L,R):
  if l == r:
    print(l+1)

Submission status: Wrong Answer

Solution code:
import collections as c

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


A = c.Counter(L+R)
ans = []
for k,v in zip(A.keys(), A.values()):
	if v == 2:
		ans.append(k)

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

Submission status: Wrong Answer

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

ans = list(set(R) & set(L))
ans.sort()
if -1 not in ans:
  for a in ans:
    print(a+1)

Submission status: Wrong Answer

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

ans = list(set(R) & set(L))
ans.sort()
for a in ans:
  print(a+1)

Submission status: Wrong Answer

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

ans = list(set(R) & set(L))
for a in ans:
  print(a+1)

Submission status: Wrong Answer

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
    print(i, count)
    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: Wrong Answer

Solution code:
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from bisect import bisect_left

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

    cuml = [0] * (n + 1)
    cumr = [0] * (n + 1)
    idx = []

    for i in range(n):
        if s[i] == 'o':
            idx.append(i)
            cuml[i + 1] = cuml[max(i - c,0)] + 1
        else:
            cuml[i + 1] = cuml[i]
    
    for i in range(n - 1,-1,-1):
        if s[i] == 'o':
            cumr[i] = cumr[min(i + c + 1,n)] + 1
        else:
            cumr[i] = cumr[i + 1]
    
    ans = []
    for i in idx:
        flag = False
        if cuml[i] >= k or cumr[i + 1] >= k:
            continue

        if i - c >= 0:
            for j in range(i - c,i):
                if cuml[j + 1] + cumr[min(j + c + 1,n)] >= k:
                    flag = True
                    break
        else:
            for j in range(i):
                if cuml[j + 1] + cumr[min(j + c + 1,n)] >= k:
                    flag = True
                    break

        if flag:
            continue
        else:
            ans.append(i + 1)
    
    for i in range(len(ans)):
        print(ans[i])
 
if __name__ =='__main__':
    main()

Submission status: Wrong Answer

Solution code:
import collections as c

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

L = []

cond = 1
rest = 0
for i in range(N):
	if cond == 1:
		if P[i] == 1:
			L.append(i)
			cond = 0

	if cond == 0:
		if rest == C:
			cond = 1
			rest = 0
		else:
			rest += 1
	if len(L) == K:
		break

cond = 1
rest = 0
for i in reversed(range(N)):
	if cond == 1:
		if P[i] == 1:
			L.append(i)
			cond = 0

	if cond == 0:
		if rest == C:
			cond = 1
			rest = 0
		else:
			rest += 1
	if len(L) == 2*K:
		break
L = c.Counter(L)

ans = []
for k,v in zip(L.keys(), L.values()):
	if v == 2:
		ans.append(k+1)

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

Submission status: Wrong Answer

Solution code:
import collections as c

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

L = []

cond = 1
rest = 0
for i in range(N):
	if cond == 1:
		if P[i] == 1:
			L.append(i)
			cond = 0

	if cond == 0:
		if rest == C:
			cond = 1
			rest = 0
		else:
			rest += 1

cond = 1
rest = 0
for i in reversed(range(N)):
	if cond == 1:
		if P[i] == 1:
			L.append(i)
			cond = 0

	if cond == 0:
		if rest == C:
			cond = 1
			rest = 0
		else:
			rest += 1
			
L = c.Counter(L)

ans = []
for k,v in zip(L.keys(), L.values()):
	if v == 2:
		ans.append(k+1)

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

Submission status: Wrong Answer

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

n,k,c = map(int,input().split())
s = list(input())
ans1 = set()
ans2 = set()
count = 0
pena = 0
for i in range(n):
    if s[i] == "o":
        if pena == 0:
            count += 1
            pena = c+1
            ans1.add(i+1)
    if pena > 0:
        pena -= 1
    if count == k:
        break
if count < k:
    ans1 = set()
pena = count = 0
for i in range(n-1,-1,-1):
    if s[i] == "o":
        if pena == 0:
            count += 1
            pena = c+1
            ans2.add(i+1)
    if pena > 0:
        pena -= 1
    if count == k:
        break
if count < k:
    ans2 = set()
ans = ans1 & ans2

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

Submission status: Wrong Answer

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

n,k,c = map(int,input().split())
s = list(input())
ans1 = set()
ans2 = set()
count = 0
pena = 0
for i in range(n):
    if s[i] == "o":
        if pena == 0:
            count += 1
            pena = c+1
            ans1.add(i+1)
    if pena > 0:
        pena -= 1
    if count == k:
        break
pena = count = 0
for i in range(n-1,-1,-1):
    if s[i] == "o":
        if pena == 0:
            count += 1
            pena = c+1
            ans2.add(i+1)
    if pena > 0:
        pena -= 1
    if count == k:
        break

ans = ans1 & ans2

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

Submission status: Wrong Answer

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

n,k,c = map(int,input().split())
s = list(input())
ans1 = set()
ans2 = set()
count = 0
pena = 0
for i in range(n):
    if s[i] == "o":
        if pena == 0:
            count += 1
            pena = c+1
            ans1.add(i+1)
    if pena > 0:
        pena -= 1
    if count == k:
        break
pena = count = 0
for i in range(n-1,-1,-1):
    if s[i] == "o":
        if pena == 0:
            count += 1
            pena = c+1
            ans2.add(i+1)
    if pena > 0:
        pena -= 1
    if count == k:
        break

ans = ans1 & ans2
if not ans:
    print()
for i in sorted(ans):
    print(i)

Submission status: Wrong Answer

Solution code:
import itertools


def main():
    n, k, c = [int(x) for x in input().split()]
    s = input()
    interval = c + 1
    late = []

    def greedy_working(s):
        i = 0
        _set = set()
        while len(_set) < k:
            if s[i] == 'o':
                _set.add(i)
                i += interval
            else:
                i += 1
        return _set

    earl = greedy_working(s)
    late = {n - d - 1 for d in greedy_working(s[::-1])}
    must_work = list(earl & late)
    if len(must_work) == 0:
        return
    must_work.sort()
    for d in must_work:
        print(d + 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import itertools


def main():
    n, k, c = [int(x) for x in input().split()]
    s = input()
    interval = c + 1
    late = []

    def greedy_working(s):
        i = 0
        _set = set()
        while len(_set) < k:
            if s[i] == 'o':
                _set.add(i)
                i += interval
            else:
                i += 1
        return _set

    earl = greedy_working(s)
    late = {n - d - 1 for d in greedy_working(s[::-1])}
    must_work = list(earl & late)
    must_work.sort()
    for d in must_work:
        print(d + 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
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.append(T[-i-1])
      
for i in range(K):
  if a[i]==b[-i-1]:
    print(a[i]+1)

Submission status: Wrong Answer

Solution code:
def work(S, k, c):
    t = 0
    for i, s in enumerate(S):
        if s == 'o' and t == 0:
            yield i
            t = c
        else:
            t = max(t-1, 0)


n, k, c = map(int, input().split())
S = list(input())
L = [i+1 for i in work(S, k, c)]
R = [n-i for i in work(S[::-1], k, c)][::-1]
for l, r in zip(L, R):
    if l == r:
        print(l)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, k, c = map(int, input().split())  #k日働く/c日間空ける
s = str(input())

l = []  #x回目に働くのはl[x]日目以降
flag = 0
i = 0
while flag < k and i < n:
  if flag == 0:
    if s[i] == "o":
      l.append(i)
      flag += 1
  else:
    i += 1
    if s[i] == "o" and l[-1] + c < i:
      l.append(i)
      flag += 1

r = []  #x回目に働くのはr[x]日目以前
flag2 = 0
j = n-1
while flag2 < k and j > 0:
  if flag2 == 0:
    if s[j] == "o":
      r.append(j)
      flag2 += 1
  else:
    j -= 1
    if s[j] == "o" and r[-1] - c > j:
      r.append(j)
      flag2 += 1

common = set(l) & set(r)
ans = list(common)
ans = map(lambda x: x+1, ans)
print(*ans, sep = "\n")

Submission status: Wrong Answer

Solution code:
n, k, c = map(int, input().split())  #k日働く/c日間空ける
s = str(input())

l = []  #x回目に働くのはl[x]日目以降
flag = 0
i = 0
while flag < k and i < n:
  if flag == 0:
    if s[i] == "o":
      l.append(i)
      flag += 1
  else:
    i += 1
    if s[i] == "o" and l[-1] + c < i:
      l.append(i)
      flag += 1

r = []  #x回目に働くのはr[x]日目以前
flag2 = 0
j = n-1
while flag2 < k and j > 0:
  if flag2 == 0:
    if s[j] == "o":
      r.append(j)
      flag2 += 1
  else:
    j -= 1
    if s[j] == "o" and r[-1] - c > j:
      r.append(j)
      flag2 += 1

common = set(l) & set(r)
ans = list(common)
ans = map(lambda x: x+1, ans)
print(*ans, sep = "\n")

Submission status: Wrong Answer

Solution code:
def main():
    n, k, c = map(int, input().split())
    s = list(input())
    right = [False]*n
    left = [False]*n
    nl = [None]*n
    nr = [None]*n
    rp = [-c]*n
    lp = [n+c]*n
    i = 0
    while i < n:
        if s[i] == "o":
            left[i] = True
            i += c+1
        else:
            i += 1
    i = n - 1
    while i >= 0:
        if s[i] == "o":
            right[n-i-1] = True
            i -= c+1
        else:
            i -= 1
    cntl, cntr = 0, 0
    pl, pr = -c, n+c
    for i, (l, r) in enumerate(zip(left, right)):
        nl[i], nr[i]  = cntl, cntr
        lp[i] = pl
        rp[i] = pr
        if l:
            pl = i+1
        if r:
            pr = n-i
        cntl += l
        cntr += r
    for i in range(n):
        if s[i] == "o":
            num = nl[i]+nr[n-i-1]
            if rp[i]-lp[n-i-1] <= c:
                num -= 1
            if num < k:
                print(i+1)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, k, c = map(int, input().split())
    s = list(input())
    right = [False]*n
    left = [False]*n
    nl = [None]*n
    nr = [None]*n
    rp = [-c]*n
    lp = [n+c]*n
    i = 0
    while i < n:
        if s[i] == "o":
            left[i] = True
            i += c+1
        else:
            i += 1
    i = n - 1
    while i >= 0:
        if s[i] == "o":
            right[n-i-1] = True
            i -= c+1
        else:
            i -= 1
    cntl, cntr = 0, 0
    pl, pr = -c, n+c
    for i, (l, r) in enumerate(zip(left, right)):
        nl[i], nr[i]  = cntl, cntr
        lp[i] = pl
        rp[i] = pr
        if l:
            pl = i+1
        if r:
            pr = n-i
        cntl += l
        cntr += r
    for i in range(n):
        num = nl[i]+nr[n-i-1]
        if rp[i]-lp[n-i-1] <= c:
            num -= 1
        if num < k:
            print(i+1)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, k, c = map(int, input().split())
    s = list(input())
    right = [False]*n
    left = [False]*n
    nl = [None]*n
    nr = [None]*n
    rp = [-c]*n
    lp = [n+c]*n
    i = 0
    while i < n:
        if s[i] == "o":
            left[i] = True
            i += c+1
        else:
            i += 1
    i = n - 1
    while i >= 0:
        if s[i] == "o":
            right[n-i-1] = True
            i -= c+1
        else:
            i -= 1
    cntl, cntr = 0, 0
    pl, pr = -c-1, n+c+1
    for i, (l, r) in enumerate(zip(left, right)):
        nl[i], nr[i]  = cntl, cntr
        lp[i] = pl
        rp[i] = pr
        if l:
            pl = i+1
        if r:
            pr = n-i
        cntl += l
        cntr += r
    for i in range(n):
        num = nl[i]+nr[n-i-1]
        if rp[i]-lp[n-i-1] < c:
            num -= 1
        if num < k:
            print(i+1)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, k, c = map(int, input().split())
    s = list(input())
    right = [False]*n
    left = [False]*n
    nl = [None]*n
    nr = [None]*n
    rp = [-c]*n
    lp = [n+c]*n
    i = 0
    while i < n:
        if s[i] == "o":
            left[i] = True
            i += c+1
        else:
            i += 1
    i = n - 1
    while i >= 0:
        if s[i] == "o":
            right[n-i-1] = True
            i -= c+1
        else:
            i -= 1
    cntl, cntr = 0, 0
    pl, pr = -c, n+c
    for i, (l, r) in enumerate(zip(left, right)):
        nl[i], nr[i]  = cntl, cntr
        lp[i] = pl
        rp[i] = pr
        if l:
            pl = i+1
        if r:
            pr = n-i
        cntl += l
        cntr += r
    for i in range(n):
        num = nl[i]+nr[n-i-1]
        if rp[i]-lp[n-i-1] < c:
            num -= 1
        if num < k:
            print(i+1)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

cnt = 0
d = c + 1 # 働いた日:iからの経過日数
no = 0 # d <= c 内にあったoの数
f = 0
ans = []
cand = []
l = n

# x * c で隔てられた区間ごとに見る
# 各区間について左から貪欲に働くのが最適
# 貪欲見ていった結果末尾を働いた場合、それ以外に最大値を達成する方法はない
for i in range(n):
    if d > c:
        if no == 0 and cand: 
            ans.extend(cand)
            cand = []
        if s[i] == 'x' and i - l == c:
            cand = []
            l = n
        if s[i] == 'o':
            cnt += 1
            d = 0
            no = 0
            cand.append(i+1)
    else:
        if s[i] == 'o':
            no += 1
            l = i
    d += 1


if no == 0 and cand: 
    ans.extend(cand)

# カツカツな場合はansを出力
if cnt == k:
    for ansi in ans:
        print(ansi)

Submission status: Wrong Answer

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

cnt = 0
d = c + 1 # 働いた日:iからの経過日数
no = 0 # d <= c 内にあったoの数
f = 0
ans = []
cand = []


# x * c で隔てられた区間ごとに見る
# 各区間について左から貪欲に働くのが最適
# 貪欲見ていった結果末尾を働いた場合、それ以外に最大値を達成する方法はない
for i in range(n):
    if d > c:
        if no == 0 and cand: 
            ans.extend(cand)
            cand = []
        if s[i] == 'o':
            cnt += 1
            d = 0
            no = 0
            cand.append(i+1)
    else:
        if s[i] == 'o':
            no += 1
    d += 1


if no == 0 and cand: 
    ans.extend(cand)

# カツカツな場合はansを出力
if cnt == k:
    for ansi in ans:
        print(ansi)

Submission status: Wrong Answer

Solution code:
n, k, c = map(int, input().split())
S = list(input())
L = []
on = True
cnt = 0
for i, s in enumerate(S):
    if not on:
        if cnt == c:
            on = True
        cnt += 1
    if on and s == 'o':
        on = False
        cnt = 0
        L.append(i)
        if len(L) == k:
            break
S.reverse()
R = []
on = True
cnt = 0
for i, s in enumerate(S):
    if not on:
        if cnt == c:
            on = True
        cnt += 1
    if on and s == 'o':
        on = False
        cnt = 0
        R.append(n-1-i)
        if len(R) == k:
            break
X = set(L) & set(R)
X = sorted(list(X))
for x in X:
    print(x+1)