#abc300f. F - More Holidays

F - More Holidays

Score : 500500 points

问题描述

你得到一个长度为 NN 的字符串 SS,其中包含字符 ox,以及整数 MMKK
保证字符串 SS 中至少包含一个 x

TT 为通过将 SS 重复拼接 MM 次得到的长度为 NMNM 的字符串。考虑在 TT 中恰好替换 KKxo
你的目标是在变换后的 TT 中得到尽可能长的连续 o 子串。
找出你能得到的最长连续 o 子串的长度。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

You are given a string SS of length NN consisting of o and x, and integers MM and KK.
SS is guaranteed to contain at least one x.

Let TT be the string of length NMNM obtained by concatenating MM copies of SS. Consider replacing exactly KK x's in TT with o.
Your objective is to have as long a contiguous substring consisting of o as possible in the resulting TT.
Find the maximum length of a contiguous substring consisting of o that you can obtain.

Constraints

  • NN, MM, and KK are integers.
  • 1N3×1051 \le N \le 3 \times 10^5
  • 1M1091 \le M \le 10^9
  • 1Kx1 \le K \le x, where xx is the number of x's in the string TT.
  • SS is a string of length NN consisting of o and x.
  • SS has at least one x.

Input

The input is given from Standard Input in the following format:

NN MM KK

SS

Output

Print the answer as an integer.

Sample Input 1

10 1 2
ooxxooooox

Sample Output 1

9

S=S= ooxxooooox and T=T= ooxxooooox.
Replacing x at the third and fourth characters with o makes T=T= ooooooooox.
Now we have a length-99 contiguous substring consisting of o, which is the longest possible.

Sample Input 2

5 3 4
oxxox

Sample Output 2

8

S=S= oxxox and T=T= oxxoxoxxoxoxxox.
Replacing x at the 5,7,85,7,8 and 1010-th characters with o makes T=T= oxxooooooooxxox.
Now we have a length-88 contiguous substring consisting of o, which is the longest possible.

Sample Input 3

30 1000000000 9982443530
oxoxooxoxoxooxoxooxxxoxxxooxox

Sample Output 3

19964887064

update @ 2024/3/10 08:24:49