#K69747. Garden Renovation Challenge

    ID: 33155 Type: Default 1000ms 256MiB

Garden Renovation Challenge

Garden Renovation Challenge

In this problem, you are given a garden consisting of n flowers. The state of each flower is represented as a character: a lowercase letter indicates its color, while a question mark ('?') represents a faded flower that can be repainted. There are m possible colors available, specifically the first m lowercase letters of the English alphabet. Your goal is to determine whether it is possible to repaint the faded flowers such that there is at least one contiguous segment of k flowers all having the same color.

Input Format:
The first line contains three integers n, m, and k separated by spaces. The second line contains a string of length n, representing the current state of the garden.

Output Format:
Print YES to standard output if it is possible to achieve the goal, or NO if it is not possible.

Note: You are allowed to repaint faded (i.e. '?') flowers into any of the m colors, but you cannot change the color of a flower that already has a color different from your chosen one for the contiguous segment.

inputFormat

The input is read from standard input (stdin) and consists of two lines. The first line contains three space-separated integers: n (the number of flowers), m (the number of available colors), and k (the required length of a consecutive segment). The second line contains a string of length n. Each character in the string is either a lowercase letter representing the current color of a flower or a '?' representing a faded flower.

outputFormat

The output is a single line written to standard output (stdout). Print 'YES' if it is possible to repaint the faded flowers such that at least k consecutive flowers are of the same color; otherwise, print 'NO'.## sample

5 3 3
a?a??
YES

</p>