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:
import sys
sys.setrecursionlimit(10**9)
N,K,C = map(int,input().split())
S = input()

i=0
forward = set()
while N>i and len(forward) < K:
    if S[i] == "o":
        forward.add(i)
        i+=C+1
    else:
        i+=1

i=N-1
backward = set()
while i>=0 and len(backward) < K:
    if S[i] == "o":
        backward.add(i)
        i-=C+1
    else:
        i-=1
    
# print(forward, backward)
isect = forward&backward
for i in sorted(isect):
    print(i+1)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k,c = LI()
s = input()

cnt = 0
i = n-1
d = defaultdict(int)
while i >= 0:
    if s[i] == 'o':
        cnt += 1
        d[i] = 1
        i -= c
    i -= 1
i = 0
f = defaultdict(int)
while i < n:
    if s[i] == 'o':
        f[i] = 1
        i += c
    i += 1
if cnt > k:
    quit()
for i,j in f.items():
    if d[i]:
        print(i+1)

Submission status: Wrong Answer

Solution code:
import numpy as np


n, k, c = map(int, input().split())
s = input()
workable = np.array([c == 'o' for c in s], dtype=np.bool)

idx = n - 1
work_set = set()
while len(work_set) < k:
    if workable[idx]:
        work_set.add(idx)
        idx -= c
    idx -= 1

idx = 0
work_cnt = 0
while work_cnt < k:
    if workable[idx]:
        work_cnt += 1
        if idx in work_set:
            print(idx + 1)
        idx += c
    idx += 1

Submission status: Wrong Answer

Solution code:
N, K, C = map(int, input().split())
S = input()
L = [-float('inf')]
R = [float('inf')]
for i, v in enumerate(S):
    if v == 'o' and i - L[-1] >= C+1:
        L.append(i)

for i in range(N-1, -1, -1):
    if S[i] == 'o' and R[0] - i >= C+1:
        R = [i] + R

for i in sorted(set(L) & set(R)):
    print(i+1)

Submission status: Wrong Answer

Solution code:
N,K,C = map(int, input().split(' '))
S = input()
ans = []
s =  [i for i, x in enumerate(S) if x == "o"]
p = 0 
l = len(S)-1
L = []
R =[]
i = 0 
j = 0
while p < N : 
  if S[p] == "o":
    L.append(p)
    p += C
  p += 1
j = 0
while l > 0:
  if S[l] == "o":
    R.append(l)
    l -= C
  l -= 1

for i in [x for x in L if x in R]:
  print(i+1)

Submission status: Wrong Answer

Solution code:
N,K,C = map(int, input().split(' '))
S = input()
ans = []
s =  [i for i, x in enumerate(S) if x == "o"]
p = 0 
l = len(S)-1
L = []
R =[]
i = 0 
j = 0
while p < N : 
  if S[p] == "o":
    L.append(p)
    p += C
  p += 1
j = 0
while l > 0:
  if S[l] == "o":
    R.append(l)
    l -= C
  l -= 1

for i in [x for x in L if x in R]:
  print(i)

Submission status: Wrong Answer

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

right = []
i = len(s2)-1
while i >= 0:
  if k2 == 0:
    break
  if s2[i] == "o":
    right.append(i+1-c)
    k2 -= 1
    i -= c
  i -= 1

ans = sorted(list(set(left) & set(right)))
for i in ans:
  print(i)

Submission status: Wrong Answer

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


count = 0
i = 0
ansleft = set()
while i < n:
    if s[i] == "o":
        ansleft.add(i+1)
        i += c+1
        count += 1
    else:
        i += 1

if count >= n+1:
    sys.exit()


ansright = set()
s = s[::-1]
i = 0
while i < n:
    if s[i] == "o":
        ansright.add(n-i)
        i += c+1
    else:
        i += 1

ans = ansright&ansleft
ans = list(ans)
ans.sort()
for i in ans:
    print(i)

Submission status: Wrong Answer

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

right = []
i = len(s2)-1
while i >= 0:
  if k2 == 0:
    break
  if s2[i] == "o":
    right.append(i+1-c)
    k -= 1
    i -= c
  i -= 1

ans = sorted(list(set(left) & set(right)))
for i in ans:
  print(i)

Submission status: Wrong Answer

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

right = []
i = len(s2)-1
while i >= 0:
  if k2 == 0:
    break
  if s2[i] == "o":
    right.append(i+1-c)
    s2 = s2[:i-c]+"x"*(len(s2)-i+c)
    #print(s2)
    k -= 1
    i -= c
  i -= 1
#print(left, right)

ans = sorted(list(set(left) & set(right)))
for i in ans:
  print(i)

Submission status: Wrong Answer

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n,k,c = m()

s = list(input())[:-1]


dp0 = [0 for i in range(n)]
dp1 = [0 for i in range(n)]
co = 0
po = 0
for i in range(n):
    if co == 0:
        if s[i] == "o":
            po += 1
            dp0[i] = po
            co = c

    else:
        co -= 1

co = 0

po += 1
for i in range(n-1,-1,-1):
    if co == 0:
        if s[i] == "o":
            po -= 1
            dp1[i] = po
            co = c

    else:
        co -= 1
        

for i in range(n):
    if dp0[i] == dp1[i] and s[i] == "o" and dp0[i]:
        print(i+1)

Submission status: Wrong Answer

Solution code:
from bisect import *

N, K, C = map(int, input().split())
S = input()
T = [i for i, x in enumerate(S, 1) if x == 'o']
sl = set()
sr = set()
i = 0
while len(sl) < K:
    sl.add(T[i])
    i = bisect_right(T, T[i]+C) 
i = len(T)-1
while len(sr) < K:
    sr.add(T[i])
    i = bisect_left(T, T[i]-C)-1
print(*sorted(list(sl & sr)), sep = '\n')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n, k, c = map(int, input().split())
s = input()

if c == 0:
    if s.count("o") == k:
        print(*range(1, n + 1), sep="\n")
    exit()

left = []
i = 0
while i < n:
    if s[i] == "o":
        left.append(i)
        i += c
    i += 1

right = []
i = n - 1
while i >= 0:
    if s[i] == "o":
        right.append(i)
        i -= c
    i -= 1
right.reverse()
for i in range(len(left)):
    if left[i] == right[i]:
        print(left[i] + 1)

Submission status: Wrong Answer

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

right = []
i = len(s2)-1
while i >= 0:
  if k2 == 0:
    break
  if s2[i] == "o":
    right.append(i+1-c)
    s2 = s2[:i-c]+"x"*(len(s2)-i+c)
    #print(s2)
    k -= 1
    i -= c
  i -= 1
#print(left, right)

ans = list(set(left) & set(right))
for i in ans:
  print(i)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)
N,K,C = map(int,input().split())
S = input()

i=0
forward = set()
while N>i and len(forward) < K:
    if S[i] == "o":
        forward.add(i)
        i+=C+1
    else:
        i+=1

i=N-1
backward = set()
while i>=0 and len(backward) < K:
    if S[i] == "o":
        backward.add(i)
        i-=C+1
    else:
        i-=1
    
# print(forward, backward)
isect = forward&backward
for i in isect:
    print(i+1)
if len(isect) == 0:
    print()

Submission status: Wrong Answer

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

ans = set()
cnt = 0
kcn = 0
for i,x in enumerate(s[::-1]):
    i = n - i - 1
    if cnt:
        cnt -= 1
    elif x == 'o' and kcn < k:
        cnt += c
        kcn += 1
        ans.add(i)

cnt = 0
j = len(ans) - 1
kcn = 0
for i,x in enumerate(s):
    if cnt:
        cnt -= 1
    elif x == 'o' and kcn < k:
        cnt += c
        kcn += 1
        if i in ans:
            print(i+1)

Submission status: Wrong Answer

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

right = []
for i in range(len(s2)-1, 0-1, -1):
  if k2 == 0:
    break
  if s2[i] == "o":
    right.append(i+1-c)
    s2 = s2[:i-c]+"x"*(len(s2)-i+c)
    #print(s2)
    k -= 1
#print(left, right)

ans = list(set(left) & set(right))
for i in ans:
  print(i)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)
N,K,C = map(int,input().split())
S = input()

i=0
forward = set()
while N>i and len(forward) < K:
    if S[i] == "o":
        forward.add(i)
        i+=C+1
    else:
        i+=1

i=N-1
backward = set()
while i>=0 and len(backward) < K:
    if S[i] == "o":
        backward.add(i)
        i-=C+1
    else:
        i-=1
    
isect = forward&backward
for i in isect:
    print(i+1)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n, k, c = map(int, input().split())
s = input()

if c == 0:
    if n == k:
        print(*range(1, n + 1), sep="\n")
    exit()

left = []
i = 0
while i < n:
    if s[i] == "o":
        left.append(i)
        i += c
    i += 1

right = []
i = n - 1
while i >= 0:
    if s[i] == "o":
        right.append(i)
        i -= c
    i -= 1
right.reverse()
for i in range(len(left)):
    if left[i] == right[i]:
        print(left[i] + 1)

Submission status: Wrong Answer

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

def main():
    N,K,C = map(int,input().split())
    s = input()
    wf,wb = [],[]
    
    now = -10**10
    for i,st in enumerate(s):
        if st == "o" and i+1 > now+C:
            wf.append(i+1)
            now = i+1
            
    now = 10**10
    s = s[::-1]
    for i,st in enumerate(s):
        if st == "o" and N-i < now-C:
            wb.append(N-i)
            now = N-i
            
    for f,b in zip(wf,wb[::-1]):
        if f == b:
            print(f)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k,c = LI()
s = input()
l,r = [False]*n, [False]*n
i = 0
while i < n:
    if s[i] == 'o':
        l[i] = True
        i += c
    i += 1
i = n-1
while i >= 0:
    if s[i] == 'o':
        r[i] = True
        i -= c
    i -= 1

for i in range(n):
    if l[i] and r[i]:
        print(i+1)

Submission status: Wrong Answer

Solution code:
import itertools, copy

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

index_num = [n for n, v in enumerate(s) if v == "o"]

comb = list(itertools.combinations(index_num, k))

for co in comb:
    ju = True
    for i in range(len(co)-1):
        if co[i+1] - co[i] < c:
            ju = False
            
    if ju:
        for i in range(len(s)):
            if not i in co:
                s[i] = "x"

index_num = [n for n, v in enumerate(s) if v == "o"]

for i, ind in enumerate(index_num):
    print(index_num[i] + 1)

Submission status: Wrong Answer

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

if n == 1:
    print(1)
    exit()

pre = [0]*n
pre[0] = 1 if S[0] == "o" else 0
for i in range(1, n):
    if S[i] == "o" and i-c-1 >= 0:
        pre[i] = max(pre[i-1], pre[i-c-1]+1)
    else:
        pre[i] = pre[i-1]

suf = [0]*n
suf[-1] = 1 if S[-1] == "o" else 0
for i in range(n-2, -1, -1):
    if S[i] == "o" and i+c+1 < n:
        suf[i] = max(suf[i+1], suf[i+c+1]+1)
    else:
        suf[i] = suf[i+1]

# print(pre)
# print(suf)

if S[0] == "o" and suf[1] < k:
    print(1)

for i in range(1, n-1):
    if S[i] == "o" and pre[i-1]+suf[i+1] < k:
        print(i+1)

if S[-1] == "o" and pre[-2] < k:
    print(n)

Submission status: Wrong Answer

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

    if c == 0:
        if n == k:
            ret = range(n)
        else:
            ret = []

    else:

        go = set()
        back = set()

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

        if len(go) < k:
            return

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

        if len(back) < k:
            return

        isec = go & back

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

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

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

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

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

mylist = []
tmp = []

passed = 0
# front
for i in range(N):
    if passed > 0:
        passed -= 1
        continue
    if S[i] == "o":
        tmp.append(i)
        passed = C
    if len(tmp) == K:
        break
     
f_res = tmp if len(tmp) == K else []

tmp = []
passed = 0
for i in range(N-1,0,-1):
    if passed > 0:
        passed -= 1
        continue
    if S[i] == "o":
        tmp.append(i)
        passed = C
    if len(tmp)== K:
        break

b_res = tmp if len(tmp) == K else []

if len(f_res) == 0:
    for v in b_res:
        print(v+1)
    exit()
if len(b_res) == 0:
    for v in f_res:
        print(v+1)
    exit()
for v in f_res:
    if v in b_res:
        print(v+1)

Submission status: Wrong Answer

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

    if c == 0:
        if n == k:
            ret = range(1, n + 1)
        else:
            ret = []

    else:

        go = set()
        back = set()

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

        if len(go) < k:
            return

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

        if len(back) < k:
            return

        isec = go & back

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

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

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

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k,c = LI()
s = input()
t = []
for i in range(n):
    if s[i] == 'o':
        t.append(1)
    else:
        t.append(0)

r = [False]*n
l = [False]*n
flag = True
for i in range(n):
    if flag and t[i] == 1:
        flag = False
        l[i] = True
        cnt = 0
        continue
    if not flag:
        cnt += 1
    if not flag and cnt == c:
        flag = True

flag = True
for i in range(n)[::-1]:
    if flag and t[i] == 1:
        flag = False
        r[i] = True
        cnt = 0
        continue
    if not flag:
        cnt += 1
    if not flag and cnt == c:
        flag = True

for i in range(n):
    if r[i] and l[i]:
        print(i+1)

Submission status: Wrong Answer

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

A = list()
B = list()

i = 0
num = 0
while num < K:
  if S[i] == "o":
    A.append(i)
    num += 1
    i += C
  i += 1
i = len(S)-1
num = 0
while num < K:
  if S[i] == "o":
    B.append(i)
    num+=1
    i -= C
  i -= 1
B.sort()

print(A)
print(B)

for i,j in zip(A,B):
  if i == j:
    print(i+1)

Submission status: Wrong Answer

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

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

days2=[]
i=N-1
while i>=0:
    if S[i]=='o':
        days2.append(i)
        i-=C
    if len(days2)>=K:
        break
    i-=1

ans=set(days)&set(days2)
ans=sorted(list(ans))
for i in ans:
    print(i+1)

Submission status: Wrong Answer

Solution code:
N, K, C=map(int, input().split())
S=input()
A=set()
i=0
while len(A)<K:
  if S[i]=='o':
    A.add(i)
    i+=C+1
  else:
    i+=1
    
B=set()
i=-1
while len(B)<K:
  if S[i]=='o':
    B.add(N+i)
    i-=(C+1)
  else:
    i-=1
    
A=list(A)
for i in A:
  if i in B:
    print(i+1)

Submission status: Wrong Answer

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

DP1 = []
DP2 = []

day = 0
while day < n:
    if S[day] == 'o':
        DP1.append(day)
        day += c + 1

    else:
        day += 1

day = n-1
while day >= 0:
    if S[day] == 'o':
        DP2.append(day)
        day -= c + 1
    else:
        day -= 1

for day1, day2 in zip(DP1, DP2[::-1]):
    if day1 == day2:
        print(day1+1)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from itertools import combinations
def get_index(lst=None,item=None):
    return [i for i in range(len(lst)) if lst[i]==item]
def choos(lst=None,C=None):
    fff=[a - b for a, b in zip(lst[1:], lst[:-1])]
#    print(fff)
    if len(fff)>0 and C<min(fff):
        return 1
    else:
        return 0
def choos_index(lst=None,C=None):
    return [i for i in range(len(lst)) if choos(lst[i],C)==1]
N,K,C= map(int,input().split())
S=list(input())
ind=get_index(S,'o')
All=list(combinations(ind, K))
CAll=choos_index(All,C)
lit=[1]*N
if len(CAll)==0:
    lit=[]
for i in CAll:
    litO=[0]*N
    for j in All[i]:
        litO[j]=1
    lit=[a * b for a, b in zip(lit, litO)]
indX=get_index(lit,1)
for i in indX:
    print(i+1)

Submission status: Wrong Answer

Solution code:
#N, K, C = map(int, raw_input().split())
#S = raw_input()
N, K, C = 16, 16, 1
S = "ooxxoxoxxxoxoxxo"

workCnt = [0]*(N+1)
res = []
def work(KK, CC, SS, pos, NN):
    if KK <= 0:
        for p in res:
            workCnt[p] = workCnt[p] + 1
        return 1

    if pos >= NN:
        return 0

    #work ok
    cnt = 0
    if SS[pos] == 'o':
        res.append(pos)
        cnt = cnt + work(KK-1, CC, SS, pos+CC, NN)
        res.pop()

    #for ii in range(pos + 1, NN):
    cnt = cnt + work(KK, CC, SS, pos+1, NN)

    return cnt


total = work(K, C+1, S, 0, N)
if total > 0:
    for i in range(N):
        if workCnt[i] >= total:
            print(i+1)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# E - Yutori
# モジュールのインポート
import itertools

# 標準入力の取得
N,K,C = list(map(int, input().split()))
S = input()

# 求解処理
# "o"の日だけリスト化
shift_list = []
for n in range(N):
    if S[n] == "o":
        shift_list.append(n+1)

# 条件を満たすような組合せを全探索
result = set(shift_list)
has_work = False
for shift in itertools.combinations(shift_list, K):
    can_work = True
    for k in range(K-1):
        if abs(shift[k+1] - shift[k]) <= C:
            can_work = False
            break

    if can_work:
        has_work = True
        result &= set(shift)

# 結果出力
if has_work:
    for r in result:
        print(r)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k,c = LI()
s = input()
t = []
for i in range(n):
    if s[i] == 'o':
        t.append(1)
    else:
        t.append(0)

cnt = 0
i = 0
lst = []
while i < n:
    tmp = []
    if t[i] == 1:
        cnt += 1
        for j in range(i,min(n,i+c)):
            if t[j] == 1:
                tmp.append(j)
        i += c+1
        lst.append(tmp)
        continue
    i += 1

if cnt > k:
    quit()

m = len(lst)
for i in range(m-1):
    l = len(lst[i+1])
    cnt = 0
    for j in lst[i]:
        r = bl(lst[i+1],j+c+1)
        if r != l:
            cnt += 1
    if cnt == 1:
        print(lst[i][0]+1)
if len(lst[-1]) == 1:
    print(lst[-1][0]+1)

Submission status: Wrong Answer

Solution code:
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n,k,c = inpm()
    s = list(input())
    circle = []
    dic = defaultdict(int)
    for i in range(n):
        if s[i] == 'o':
            circle.append(i)
    pre = -c-10
    cnt = 0
    for i in range(len(circle)):
        if pre+c < circle[i]:
            dic[circle[i]] += 1
            pre = circle[i]
            cnt += 1
            if cnt == k:
                break
    pre = n+c+10
    cnt = 0
    for i in range(len(circle)-1,-1,-1):
        if pre-c > circle[i]:
            dic[circle[i]] += 1
            pre = circle[i]
            cnt += 1
            if cnt == k:
                break
    ans = []
    for e in dic:
        if dic[e] == 2:
            ans.append(e+1)
    ans.sort()
    for i in range(len(ans)):
        print(ans[i])
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from collections import deque
n, k, c = map(int, input().split())
s = str(input())

# 前後
i = 0
l1 = []
while i <= n-1:
    if s[i] == 'o':
        l1.append(i)
        i += c + 1
    else:
        i += 1
    if len(l1) >= k:
        break
i = n-1
l2 = []
while i >= 0:
    if s[i] == 'o':
        l2.append(i)
        i -= (c + 1)
    else:
        i -= 1
    if len(l2) >= k:
        break

ans = list(set(l1) & set(l2))
ans.sort()
for i in ans:
    print(i+1)

Submission status: Wrong Answer

Solution code:
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n,k,c = inpm()
    s = list(input())
    circle = []
    dic = defaultdict(int)
    for i in range(n):
        if s[i] == 'o':
            circle.append(i)
    pre = -c-10
    for i in range(len(circle)):
        if pre+c < circle[i]:
            dic[circle[i]] += 1
            pre = circle[i]
    pre = n+c+10
    for i in range(len(circle)-1,-1,-1):
        if pre-c > circle[i]:
            dic[circle[i]] += 1
            pre = circle[i]
    ans = []
    for e in dic:
        if dic[e] == 2:
            ans.append(e+1)
    ans.sort()
    for i in range(len(ans)):
        print(ans[i])
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

wc = 0
arr = ["x"] * N
arr2 = ["x"] * N
cur = 0

while cur < N:
    if S[cur] == "x":
        cur += 1
        continue
    wc += 1
    arr[cur] = wc
    cur += C + 1

cur = N - 1
wc = K + 1
while cur > 0:
    if S[cur] == "x":
        cur -= 1
        continue
    wc -= 1
    arr2[cur] = wc
    cur -= C + 1

for i, (a, b) in enumerate(zip(arr, arr2)):
    if a == b and a != "x":
        print(i + 1)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from collections import deque
import heapq
from pprint import pprint
import copy

def solve(K, S, acc, C):
    # end place
    if K == 0:
        return [S]
    elif K > S[acc + C:].count('o'):
        return []
    result = []
    for i in range(acc + C, len(S)):
        if S[i] == 'o':
            temp = copy.copy(S)
            temp[i] = 'c'
            result += solve(K - 1, temp, i, C)
    return result


def main():
    N, K, C = map(int, input().rstrip().split())
    S = input()
    S = S.replace('x', ' ').rstrip().replace(' ', 'x')
    if len(S.replace('x', '')) < K:
        return
    S = list(S)
    first = 0 - C
    res = solve(K, ['x'] + S, first, C)
    # pprint(res)
    result = [0 for _ in range(N + 1)]
    for r in res:
        for i, x in enumerate(r):
            if x == 'c':
                result[i] += 1
    for idx, r in enumerate(result):
        if r == len(res):
            print(idx)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from collections import deque
n, k, c = map(int, input().split())
s = str(input())

# 前後
i = 0
l1 = []
while i < n:
    if s[i] == 'o':
        l1.append(i)
        i += c + 1
    else:
        i += 1
    if len(l1) >= k:
        break
i = n-1
l2 = []
while i >= 0:
    if s[i] == 'o':
        l2.append(i)
        i -= (c + 1)
    else:
        i -= 1
    if len(l2) >= k:
        break

ans = list(set(l1) & set(l2))
ans.sort()
for i in ans:
    print(i+1)