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: Accepted

Solution code:
n, k, c = map(int, input().split())
s = input()
work = [1]*n

rest = 0
for i in range(n):
    if rest:
        rest -= 1
        work[i] = 0
        continue

    if s[i] == 'x':
        work[i] = 0
    elif s[i] == 'o':
        rest = c


rest = 0
for i in reversed(range(n)):
    if rest:
        rest -= 1
        work[i] = 0
        continue
    if s[i] == 'o':
        rest = c


if k < sum(work):
    print()
else:
    for idx, bl in enumerate(work):
        if bl:
            print(idx+1)

Submission status: Accepted

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 = []
    Right = []
    for u in l:
        if Left == []:
            Left.append(u)
        if u > Left[-1] + C:
            Left.append(u)
        if len(Right) == K:
            break
        
    if len(Left) <K:
        exit()

    for u in l[::-1]:
        if Right== []:
            Right.append(u)
        if u < Right[-1] - C:
            Right.append(u)
        if len(Right) == K:
            break

    if len(Right) <K:
            exit()
    
    for i in range(K):
        if Left[i] == Right[-i-1]:
            print(Left[i])

yutori()

Submission status: Accepted

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

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

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

L = list(reversed(L))

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

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, k, c = list(map(int, readline().split()))
    s = input()
    day_ealiest = []
    day_latest = []

    rest_day = 0
    work_cnt = 0
    for day, ch in enumerate(s, 1):
        if rest_day <= 0:
            if ch == "o":
                rest_day = c
                day_ealiest.append(day)
                work_cnt += 1
                if work_cnt == k:
                    break
        else:
            rest_day -= 1

    s_reversed = s[::-1]
    rest_day = 0
    work_cnt = 0
    for i, ch in enumerate(s_reversed):
        day = n - i
        if rest_day <= 0:
            if ch == "o":
                rest_day = c
                day_latest.append(day)
                work_cnt += 1
                if work_cnt == k:
                    break
        else:
            rest_day -= 1

    day_latest.reverse()

    res = []
    for de, dl in zip(day_ealiest, day_latest):
        if de == dl:
            res.append(de)

    print(*res, sep="\n")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# Problem E - Yutori

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

# initialization
left_list = [0]*(N+1)
right_list = [0]*(N+1)

# count
k = 1
i = 0
while i<N:
    if S[i]=='o':
        left_list[i+1] = k
        k += 1
        i += C + 1
    else:
        i += 1

k = K
i = N - 1
while i>=0:
    if S[i]=='o':
        right_list[i+1] = k
        k -= 1
        i -= C + 1
    else:
        i -= 1

# check
for i in range(1, N+1):
    if not left_list[i]==0 and not right_list[i]==0:
        if left_list[i]==right_list[i]:
            print(i)

Submission status: Accepted

Solution code:
# Problem E - Yutori
# 上限と下限の一致

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

# initialization
left_list = [0]*(N+1)
right_list = [0]*(N+1)

# left count
i = 0
num_count = 1
while i<N:
    c = S[i]
    if c=='o':
        left_list[i+1] = num_count
        i += C+1
        num_count += 1
    else:
        i += 1

# right count
i = N-1
num_count = K
while i>=0:
    c = S[i]
    if c=='o':
        right_list[i+1] = num_count
        i -= C+1
        num_count -= 1
    else:
        i -= 1

# check
for i in range(1, N+1):
    if not left_list[i]==0 and not right_list[i]==0:
        if left_list[i]==right_list[i]:
            print(i)

Submission status: Accepted

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(rl) != 1 or b==0:break
    if i == k:
        ans.append(i)
 
[print(i) for i in ans]

Submission status: Accepted

Solution code:
N, K, C = map(int, input().split())
S = input()
left = []
right = []
i, j = 0, N-1
while len(left) <= K-1:
    if S[i] == "o":
        left.append(i)
        i += C+1
    else:
        i += 1
while len(right) <= K-1:
    if S[j] == "o":
        right.append(j)
        j -= C+1
    else:
        j -= 1
right.sort()
for n in range(K):
    if left[n] == right[n]:
        print(left[n] + 1)

Submission status: Accepted

Solution code:
N, K, C = map(int, input().split())
S = input()
left = []
right = []
i, j = 0, N-1
while len(left) <= K-1:
    if S[i] == "o":
        left.append(i)
        i += C+1
    else:
        i += 1
while len(right) <= K-1:
    if S[j] == "o":
        right.append(j)
        j -= C+1
    else:
        j -= 1
right.sort()
for n in range(K):
    if left[n] == right[n]:
        print(left[n] + 1)

Submission status: Accepted

Solution code:


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

l = [0]*K
r = [0]*K
ld = 0
rd = N-1
for i in range(K) :
    j = K - i - 1
    while S[ld] == 'x' :
        ld += 1
    while S[rd] == 'x' :
        rd -= 1
    l[i] = ld
    ld += 1+C
    r[j] = rd
    rd -= 1+C

for i in range(K) :
    if l[i] == r[i] :
        print(l[i]+1)

Submission status: Accepted

Solution code:
n,k,c=map(int,input().split())
s=input()
l=[0]*k
r=[0]*k
ld=0
rd=n-1
for i in range(k):
  j=k-1-i
  while s[ld]=='x':
    ld+=1
  while s[rd]=='x':
    rd-=1
  l[i]=ld
  ld+=1+c
  r[j]=rd
  rd-=1+c
for i in range(k):
  if l[i]==r[i]:
    print(l[i]+1)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N, K, C = [int(x) for x in input().strip().split()]
S = [i == 'o' for i in list(input().strip())]

a = [0] * K
b = [2 * 10 ** 5] * K
c = 0
k = 0
for i, s in enumerate(S, start=1):
    if c > 0:
        c -= 1
        continue
    if s:
        a[k] = i
        k += 1
        c = C
    if k == K:
        break

c = 0
k = 0
for i, s in enumerate(S[::-1], start=1):
    if c > 0:
        c -= 1
        continue
    if s:
        b[K-k-1] = N-i+1
        k += 1
        c = C
    if k == K:
        break

for aa, bb in zip(a, b):
    if aa == bb:
        print(aa)

Submission status: Accepted

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+=c
    i+=1

i=0
while i < n:
    if s[n-i-1]=="o":
        R.append(n-i-1)
        i+=c
    i+=1
    
days=[]
for i in range(k):
    if L[i]==R[k-i-1]:
        days.append(L[i])


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

Submission status: Accepted

Solution code:
n,k,c = map(int,input().split())
S = input()
mae = []
ushiro = []
cur_1 = 0
temp_1 = 0
cur_2 = 0
temp_2 = 0
ans = []
for i in range(n):
    if S[i] == 'o' and temp_1 == 0:
        mae.append(i)
        cur_1 += 1
        temp_1 = c
    else:
        temp_1 = max(temp_1-1,0)
    if cur_1 == k:
        break
for i in range(n):
    if S[n-i-1] == 'o' and temp_2 == 0:
        ushiro.append(n-i-1)
        cur_2 += 1
        temp_2 = c
    else:
        temp_2 = max(temp_2-1,0)
    if cur_2 == k:
        break
for i in range(k):
    if mae[len(mae)-1-i] == ushiro[i]:
        ans.append(ushiro[i]+1)
if len(ans) == 0:
    None
else:
    ans.reverse()
    for i in range(len(ans)):
        print(ans[i])

Submission status: Accepted

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

L = []
lenL = 0
R = []
lenR = 0

c = 0
for i in range(N):
    if S[i] == 'o' and c <= 0:
        L.append(i + 1)
        lenL += 1
        if lenL == K:
            break
        c = C
    else:
        c -= 1

c = 0
for i in list(range(N))[::-1]:
    if S[i] == 'o' and c <= 0:
        R.append(i + 1)
        lenR += 1
        if lenR == K:
            break
        c = C
    else:
        c -= 1

for i in range(K):
    if L[i] == R[K - i - 1]:
        print(L[i])

Submission status: Accepted

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

forward = []
backward = []
i = 0
while i < len(s) and len(forward) < k:
    if s[i] == 'x':
        i += 1
        continue
    forward.append(i)
    i += c + 1
i = len(s)-1
while i > -1 and len(backward) < k:
    if s[i] == 'x':
        i -= 1
        continue
    backward.append(i)
    i -= c
    i -= 1

for i in range(len(forward)):
    if forward[i] == backward[len(backward) - i - 1]:
        print(forward[i] + 1)

Submission status: Accepted

Solution code:
n,k,c=map(int,input().split())
s=input()
if k==1:
  if s.count("o")==1:
    print(s.index("o")+1)
  exit()
l=[-c]*k
r=[n+c]*k
ll=0
for i in range(n):
  if ll==0:
    if s[i]=="o":
      l[ll]=i
      ll+=1
    continue 
  if s[i]=="x" or l[ll-1]+c>=i:continue
  l[ll]=i
  ll+=1
  if ll==k:break
rr=k-1
for i in range(n):
  if rr==k-1:
    if s[(n-1)-i]=="o":
      r[rr]=(n-1)-i
      rr-=1
    continue
  if s[(n-1)-i]=="x" or r[rr+1]-c<=(n-1)-i:continue
  r[rr]=(n-1)-i
  rr-=1
  if rr==-1:break
for i in range(k):
  if l[i]==r[i]:print(l[i]+1)

Submission status: Accepted

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

c += 1
forward = []
backward = []
i = 0
while i < len(s) and len(forward) < k:
    if s[i] == 'x':
        i += 1
        continue
    forward.append(i)
    i += c
j = len(s)-1
while j > -1 and len(backward) < k:
    if s[j] == 'x':
        j -= 1
        continue
    backward.append(j)
    j -= c

backward.reverse()
for i in range(len(forward)):
    if forward[i] == backward[i]:
        print(forward[i]+1)

Submission status: Accepted

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

    def f(r):
        interval = 0
        count = k
        for i in r:
            if count == 0:
                break
            if interval > 0:
                interval -= 1
                continue
            if s[i] == 'o':
                yield i
                count -= 1 
                interval = c

    for i, j in zip(f(range(0, n)), reversed(list(f(range(n-1, -1, -1))))):
        if i == j:
            yield str(i+1)


print("\n".join(main()))

Submission status: Accepted

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

    def f(r):
        interval = 0
        count = k
        for i in r:
            if count == 0:
                break
            if interval > 0:
                interval -= 1
                continue
            if s[i] == 'o':
                yield i
                count -= 1 
                interval = c

    for i, j in zip(f(range(0, n)), reversed(list(f(range(n-1, -1, -1))))):
        if i == j:
            yield i+1


print(*main(), sep="\n")

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")
 
 
def solve(N: int, K: int, C: int, S: str):
 
    L = []
    c = 0
    for i, d in enumerate(S):
        if d == "o" and c == 0:
            L.append(i)
            c = C
        elif c > 0:
            c -= 1
    R = []
    c = 0
    for i, d in enumerate(S[::-1]):
        if d == "o" and c == 0:
            R.append(N-i-1)
            c = C
        elif c > 0:
            c -= 1
 
    if len(L) != K:
        print()
        return
    for l, r in zip(L, R[::-1]):
        if l == r:
            print(l+1)
    return
 
 
def main():
 
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, K, C, S)
 
 
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def solve(N: int, K: int, C: int, S: str):

    L = []
    c = 0
    for i, d in enumerate(S):
        if d == "o" and c == 0:
            L.append(i)
            c = C
        elif c > 0:
            c -= 1
    R = []
    c = 0
    for i, d in enumerate(S[::-1]):
        if d == "o" and c == 0:
            R.append(N-i-1)
            c = C
        elif c > 0:
            c -= 1

    if len(L) != K:
        print()
        return
    for l, r in zip(L, R[::-1]):
        if l == r:
            print(l+1)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, K, C, S)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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

Submission status: Accepted

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

forward = dict()
backward = dict()

rep = list(range(n))
# forward
l = 0
kf = k
kb = k
while 1:
  if s[l] == 'x':
    l += 1
  else:
    forward[k-kf] = l+1
    kf -= 1
    l += c+1
  if (l > n-1) | (kf == 0):
    break
rep.reverse()
# backward
l = n-1
while 1:
  if s[l] == 'x':
    l -= 1
  else:
    backward[kb-1] = l+1
    kb -= 1
    l -= c+1
  if (l < 0) | (kb == 0):
    break
#judgement
ret = set(forward.items()) & set(backward.items())
lis = list()
for l in range(len(ret)):
  lis.append(ret.pop()[1])
lis = sorted(lis)
lis.reverse()
for l in range(len(lis)):
  print(lis.pop())

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n, k, c = map(int, input().split())
s = input()
l = [-1] * k
r = [-1] * k
nowl = 0
indl = 0
while nowl < n and indl < k:
    for i in range(nowl, n):
        if s[i] == "o":
            l[indl] = i
            nowl = i + c + 1
            indl += 1
            break
nowr = n - 1
indr = k - 1
while nowr >= 0 and indr >= 0:
    for i in range(nowr, -1, -1):
        if s[i] == "o":
            r[indr] = i
            nowr = i - c - 1
            indr -= 1
            break
for i in range(k):
    if l[i] == r[i]:
        print(l[i] + 1)

Submission status: Accepted

Solution code:
n,k,c = map(int,input().split())
s = input()
l = [0]*k
r = [0]*k

count = 0
bef = 0
for i,j in enumerate(s):
    if j == 'o':
        if count == 0:
            l[0] = i+1
            count += 1
            bef = i
        elif i > bef + c:
            l[count] = i+1
            count += 1
            bef = i
    if count == k:
        break

count = 0
bef = 0
for i,j in enumerate(s[::-1]):
    if j == 'o':
        if count == 0:
            r[0] = n-i
            count += 1
            bef = i
        elif i > bef + c:
            r[count] = n-i
            count += 1
            bef = i
    if count == k:
        break
r = r[::-1]

for i in range(k):
    if l[i] != 0 and l[i] == r[i]:
        print(l[i])

Submission status: Accepted

Solution code:
n, k, c = map(int, input().split())
c += 1
s = list(input())
a = []
i = 0
while i < len(s) and len(a) < k:
    if s[i] == 'x':
        i += 1
        continue
    a.append(i)
    i += c
b = []
j = len(s)-1
while j > -1 and len(b) < k:
    if s[j] == 'x':
        j -= 1
        continue
    b.append(j)
    j -= c
b = b[::-1]
for i in range(len(a)):
    if a[i] == b[i]:
        print(a[i] + 1)

Submission status: Accepted

Solution code:
n, k, c = map(int, input().split())
s = input()
l = len(s) - 1
i = 0
lb = []
le = []
while i < len(s) and len(lb) < k:
    if s[i] == 'o':
        lb.append(i)
        i += c + 1
        continue
    i += 1

while l > -1 and len(le) < k:
    if s[l] == 'o':
        le.append(l)
        l -= (c + 1)
        continue
    l -= 1

le.sort()
for j in range(0, len(lb)):
    if lb[j] == le[j]:
        print(lb[j]+1)

Submission status: Accepted

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

l_list, r_list = [], []
tmp = 0
b = 0

for i in range(len(s)):
    if s[i] == 'o' and b == 0 and tmp < k:
        l_list.append(i)
        tmp += 1
        b = c
    
    elif b > 0:
        b -= 1

tmp = 0
b = 0
for i in range(len(s) - 1, -1, -1):
    if s[i] == 'o' and b == 0 and tmp < k:
        r_list.append(i)
        tmp += 1
        b = c
        
    elif b > 0:
        b -= 1

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

Submission status: Accepted

Solution code:
from collections import deque
n, k, c = map(int, input().split())
s = list(map(lambda x: 1 if x == 'o' else 0, input()))
b_a = deque()
b_b = deque()
c_k = 0
for i in range(n-1, -1, -1):
    if c_k == 0 and s[i] == 1:
        b_a.append(i)
        c_k = c
    else:
        c_k = max(c_k-1, 0)
c_k = 0
for i in range(n):
    if c_k == 0 and s[i] == 1:
        b_b.append(i)
        c_k = c
    else:
        c_k = max(c_k-1, 0)

ans = list(set(b_a) & set(b_b))
ans.sort()
if len(ans) <= k:
    for i in ans:
        print(i+1)

Submission status: Accepted

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

l = []
next_workable = 0
for i in range(n):
    if next_workable <= i and s[i] == 'o':
        l.append(i)
        next_workable = i + c + 1

r = []
next_workable = n-1
for i in range(n-1, -1, -1):
    if i <= next_workable and s[i] == 'o':
        r.append(i)
        next_workable = i - c - 1
if len(l) > k:
    exit()
for i in range(k):
    if l[i] == r[-1 - i]:
        print(l[i] + 1)

Submission status: Accepted

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

i = 0
while len(L) < K:
    if S[i] == "o":
        L.append(i)
        i += C+1
    else:
        i += 1
        
i = N-1
while len(R) < K:
    if S[i] == "o":
        R.append(i)
        i -= C+1
    else:
        i -= 1
        
R = R[::-1]
for i in range(K):
    if L[i] == R[i]:
        print (L[i]+1)

Submission status: Accepted

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

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

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

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

Submission status: Accepted

Solution code:


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

    dpt1=[0]*K
    dpt2=[0]*K
    pnt = 0
    for i in range(K):
        while S[pnt]=="x":
            pnt+=1
        dpt1[i]=pnt
        pnt += C+1

    pnt = N-1
    for i in range(K-1,-1,-1):
        while S[pnt] == "x":
            pnt -=1
        dpt2[i]=pnt
        pnt-=C+1

    for a,b in zip(dpt1,dpt2):
        if a == b:
            print(a+1)
if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
n, k, c = map(int, input().split())
s = input()
l = [-1] * n
r = [-1] * n
pre = -n - 1
cnt = 0
for i in range(0, n):
    if s[i] == 'x':
        continue
    if i - pre - 1 >= c:
        l[cnt] = i + 1
        cnt += 1
        pre = i
cnt = 0
pre = 2 * n + 1
for i in range(n - 1, -1, -1):
    if s[i] == 'x':
        continue
    if pre - i - 1 >= c:
        
        r[k - cnt - 1] = i + 1
        cnt += 1
        pre = i
ans = []
for i in range(0, k):
    if l[i] == r[i] and l[i] != -1:
        ans.append(l[i])
for x in ans:
    print(x)

Submission status: Accepted

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

i = 0
while i < n and len(l) <= k:
  if s[i] == "o":
    l.append(i)
    i += (c + 1)
  else:
    i += 1

i = n-1
while i >= 0 and len(r) <= k:
  if s[i] == "o":
    r.append(i)
    i -= (c+1)
  else:
    i -= 1
  
i = 0
while i < k:
  if l[i] == r[k-1-i]:
    print(l[i]+1)
  i += 1

Submission status: Accepted

Solution code:
nkc = list(map(int, input().split()))
s = input()
ok = [i for i in range(nkc[0]) if s[i]=='o']

L = []
today = -1000000
for x in ok:
    if x-today >= nkc[2]+1:
        today = x
        L.append(x)
    if len(L) == nkc[1]:
        break

R = []
today = 1000000
ok.reverse()
for x in ok:
    if today-x >= nkc[2]+1:
        today = x
        R.append(x)
    if len(R) == nkc[1]:
        break

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

Submission status: Accepted

Solution code:
from collections import deque

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

    f = [-1 for i in range(K+1)]
    b = [-1 for i in range(K+1)]

    count = 0
    i = 0
    while i < N and count < K:
        if S[i] == 'o':
            count += 1
            f[count] = i
            i += C+1
        else:
            i += 1
    
    count = K
    j = N-1
    while j >= 0 and count > 0:
        if S[j] == 'o':
            b[count] = j
            count -= 1
            j -= C+1
        else:
            j -= 1

    i = 0
    j = N-1

    for i in range(1,K+1):
        if f[i] != -1 and f[i] == b[i]:
            print(f[i]+1)


main()

Submission status: Accepted

Solution code:
n,k,c = map(int,raw_input().split())
s = raw_input()
most = [0]*(n+1)
i = n
days = 0
while i > 0:
    if s[i-1] == 'o':
        days += 1
        for j in xrange(min(max(1,c),i-1)):
            #print days
            #print i,j,1,days
            most[i-j-1] = days
        i -= (c+1)
    else:
        i -= 1
        if i<n:
            most[i] = most[i+1]

remain = k
i = 1
while i<=n:
    if s[i-1] == 'o':
        if most[i] < remain:
            print i
        remain -= 1
        i += c+1
    else:
        i += 1

Submission status: Accepted

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

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

for i in range(k):
  if ans1[i]==ans2[i]:
    print(ans1[i]+1)

Submission status: Accepted

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

dpl = [0 for i in range(n+1)]
dpr = [0 for i in range(n+1)]

for i in range(n):
    dpl[i+1] = (dpl[i] if s[i] == 'x' else
                dpl[i-c] + 1 if i-c >= 0 else
                1)

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

for i in range(1, n+1):
    if dpl[i-1] + dpr[i] < k:
        print(i)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')

N, K, C = MI()
S = input()

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

R = list()
i = N - 1
while i >= 0:
    if len(R) >= K:
        break
    elif S[i] == 'o':
        R.append(i)
        i -= C + 1
    else:
        i -= 1
R.reverse()

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

Submission status: Accepted

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

l = []
i = 1 
# 前から貪欲
while len(l) < k:
    if s[i] == "o":
        l.append(i)
        i += c+1
    else:
        i += 1

# 後ろから貪欲
r = []
i = n

while len(r) < k:
    if s[i] == "o":
        r.append(i)
        i -= (c+1)
    else:
        i -= 1

r = r[::-1]
for i in range(len(l)):
    if l[i] == r[i]:
        print(l[i])

Submission status: Accepted

Solution code:
#入力受け取り
N, K, C=map(int, input().split())
S='x'+input() #インデックスと日数を合わせるために先頭に'x'を追加

#前詰めな働き方の場合で働く日を求める
A=[] #前詰めで働く場合の働く日リスト
i=1 #1日目から判定スタート
while len(A)<K:
  if S[i]=='o':
    #i日目に働けるなら、リストにiを追加し、iをC+1だけ進める
    A.append(i)
    i+=(C+1)
  else:
    #i日目に働けないならその日は働けないので(小泉構文)、iに1足すのみ
    i+=1
    
#後ろ詰めな働き方の場合で働く日を求める
B=[]
i=N #N日目から判定スタート
while len(B)<K:
  if S[i]=='o':
    #i日目に働けるなら、リストにiを追加し、iをC+1だけ戻す
    B.append(i)
    i-=(C+1)
  else:
    #i日目に働けないならその日は働けないので(小泉構文)、iから1引くのみ
    i-=1
    
B=B[::-1] #Bは降順に追加されているので、昇順にする
for i in range(K):
  #i番目に働くのが前詰めと後ろ詰めで同じ日であれば出力
  if A[i]==B[i]:
    print(A[i])

Submission status: Accepted

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

R = []
tmp = 0
count = 0
while tmp < N:
    if S[tmp] == 'o':
        R.append(tmp)
        count += 1
        if count == K:
            break
        tmp += C + 1
    else:
        tmp += 1

L = []
tmp = N - 1
count = 0
while tmp >= 0:
    if S[tmp] == 'o':
        L.append(tmp)
        count += 1
        if count == K:
            break
        tmp -= C + 1
    else:
        tmp -= 1

for l, r in zip(R, L[::-1]):
    # print (l, r)
    if l == r:
        print (l + 1)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc161/tasks/abc161_e


def main():
    n, k, c = map(int, input().split(" "))
    s = [s for s in input()]
    l = [0] * n
    r = [0] * n
    day = 1
    i = 0
    while day <= k and i < n:
        if s[i] == "o":
            l[i] = day
            day += 1
            i += c + 1
        else:
            i += 1
    i = n - 1
    day = k
    while day > 0 and i >= 0:
        if s[i] == "o":
            r[i] = day
            day -= 1
            i -= c + 1
        else:
            i -= 1
    for i in range(n):
        if l[i] > 0 and l[i] == r[i]:
            print(i + 1)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,k,c=map(int,input().split())
s=input()
l=[0]*n
r=[0]*n
mini=0
maxi=n-1
numl=1
numr=k
for i in range(n):
  if s[i]!='x' and i>=mini:
    l[i]=numl
    numl+=1
    mini=i+(c+1)
for i in reversed(range(n)):
  if s[i]!='x' and i<=maxi:
    r[i]=numr
    numr-=1
    maxi=i-(c+1)
for i in range(n):
  if l[i]!=0 and l[i]==r[i]:
    print(i+1)

Submission status: Accepted

Solution code:
n,k,c=map(int,input().split())
s=input()
def greedy_work(days,rest,plan):
  day_count=0
  go=[0]*n
  while day_count < days:
    if plan[day_count]=='o':
      go[day_count]=1
      day_count += rest+1
    else:
      day_count += 1
  return(go)
front = greedy_work(n,c,s)
back = greedy_work(n,c,s[::-1])
back = back[::-1]
if front.count(1)==k:
  for i in range(n):
    if front[i]==1 and back[i]==1:
      print(i+1)

Submission status: Accepted

Solution code:
"""
入力例 1 
11 3 2
ooxxxoxxxoo
->6
入力例 2 
5 2 3
ooxoo
->1
->5

入力例 3 
5 1 0
ooooo
->
入力例 4 
16 4 3
ooxxoxoxxxoxoxxo
->11
->16
"""
n,k,c = map(int,input().split())
s = input()
r=[0]*n
l=[0]*n
ki=0
ci=100000
for i in range(n):
    ci += 1
    if s[i]=='x':
        continue
    if ci > c:
        ci = 0
        ki+=1
        l[i]=ki
    if ki == k:
        break

ki=k
ci=100000
for i in range(n):
    ci += 1
    if s[n-1-i]=='x':
        continue
    if ci > c:
        ci = 0
        r[n-1-i]=ki
        ki-=1
    if ki == 0:
        break
ret=[]
for i in range(n):
    if r[i]==l[i] and r[i]!=0:
        ret.append(i+1)
# print(l)
# print(r)
for i in range(len(ret)):
  print(ret[i])

Submission status: Accepted

Solution code:
N, K, C = map(int, input().split())
S = input()
mae = [0] * (2 * N)
ato = [0] * (2 * N)

cnt = 0
n = 0 - N - 100

for i in range(N):
    if i - n <= C:
        continue

    if S[i] == 'o':
        mae[cnt] = i
        cnt += 1
        n = i

cnt = K - 1
n = 2 * N + 100

for i in range(N-1, -1, -1):
    if n - i <= C:
        continue

    if S[i] == 'o':
        ato[cnt] = i
        cnt -= 1
        n = i

for i in range(K):
    if mae[i] == ato[i]:
        print(mae[i]+1)