Problem: 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.

Submission attempts (in order):
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, C: int, S: str):
    
    work = 0
    rest = 0
    startWork = -1
    girigiriIndices = []
    for i in range(N):
        
        #     print(f"i=15{rest}")
        if S[i] == "o" and rest <= 0:
            rest = C
            work += 1
            startWork = i
        else:
            rest -= 1
    # rest = -1
    # startWork = -1
    
    #     if S[i] == "o" and rest <= 0:
    #         rest = C
    #         startWork = i
    
    #         print(f"i{i},{rest}")
    #     else:
    #         rest -= 1

    if work != K:
        print("")
        # print(work)
        exit()
    for i in girigiriIndices:
        print(i+1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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()


#!/usr/bin/env python3
import sys


def solve(N: int, K: int, C: int, S: str):
    
    work = 0
    rest = 0
    startWork = -1
    girigiriIndices = []
    for i in range(N):
        if i == 15:
            print(f"i=15{rest}")
        if S[i] == "o" and rest <= 0:
            rest = C
            work += 1
            startWork = i
        else:
            rest -= 1
    rest = -1
    startWork = -1
    for i in range(N-1, -1, -1):
        if S[i] == "o" and rest <= 0:
            rest = C
            startWork = i
            girigiriIndices.append(i)
            print(f"i{i},{rest}")
        else:
            rest -= 1

    if work != K:
        print("")
        # print(work)
        exit()
    for i in girigiriIndices:
        print(i+1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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()


#!/usr/bin/env python3
import sys


def solve(N: int, K: int, C: int, S: str):
    
    work = 0
    rest = 0
    startWork = -1
    leftIndices = set()
    rightIndices = set()
    for i in range(N):
        if S[i] == "o" and rest <= 0:
            rest = C
            work += 1
            leftIndices.add(i)
        else:
            rest -= 1
    if work != K:
        print("")
        exit()
    work = 0
    rest = 0
    for i in range(N-1, -1, -1):
        if S[i] == "o" and rest <= 0:
            rest = C
            work += 1
            rightIndices.add(i)
        else:
            rest -= 1
    for i in sorted(list(leftIndices.intersection(rightIndices))):
        print(i+1)
    
    # rest = -1
    # startWork = -1
    
    #     if S[i] == "o" and rest <= 0:
    #         rest = C
    #         startWork = i
    
    #         print(f"i{i},{rest}")
    #     else:
    #         rest -= 1

    
    #     print("")
    #     # print(work)
    #     exit()
    
    #     print(i+1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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()


Verdicts: Wrong Answer

Runtime Error

Accepted