No.2076 Concon Substrings (ConVersion)
タグ : / 解いたユーザー数 40
作問者 : 👑
nok0
Problem Statement
You are given a string $S$ of length $N$ consisting of lowercase English letters. You may now perform the operations described below.
-
In each odd-numbered operation, choose one place among the contiguous subsequences of $S$ where
conoccurs $A$ times in a row, and change it tocoon. If there is no place in the contiguous subsequences of $S$ whereconoccurs $A$ times in a row, this operation cannot be performed. -
In each even-numbered operation, choose one place among the contiguous subsequences of $S$ where
conoccurs $B$ times in a row, and change it tocoon. If there is no place in the contiguous subsequences of $S$ whereconoccurs $B$ times in a row, this operation cannot be performed.
Find the maximum number of times the operation can be performed.
Input
$N$ $A$ $B$ $S$
- $N, A, B$ are integers.
- $1 \leq N \leq 5 \times 10^4$
- $1 \leq A,B \leq N$
- $S$ is a string of length $N$ consisting of lowercase English letters.
Output
Output the answer.
Sample
Sample 1
Input
7 1 2 contest
Output
1
By operating as contest → coontest, you can perform the operation $1$ time. It is not possible to perform the operation $2$ or more times, so the answer is $1$.
Sample 2
Input
15 1 2 confoxconconfox
Output
2
By operating as confoxconconfox → coonfoxconconfox → coonfoxcoonfox, you can perform the operation $2$ times. It is not possible to perform the operation $3$ or more times, so the answer is $2$.
Sample 3
Input
19 1 1 kudamakitsukasacoon
Output
0
The operation cannot be performed even once from the start.
Sample 4
Input
21 2 3 conconconconconconcon
Output
3
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。