問題一覧 > 通常問題

No.2076 Concon Substrings (ConVersion)

レベル : / AI推定難易度 : 1900 / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 40
作問者 : 👑 AngrySadEight / テスター : nok0
お気に入りにしたユーザー ProblemId : 8362 / 自分の提出
問題文最終更新日: 2022-09-16 16:55:36
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 360 (順位表) の他の問題:

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 con occurs $A$ times in a row, and change it to coon. If there is no place in the contiguous subsequences of $S$ where con occurs $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 con occurs $B$ times in a row, and change it to coon. If there is no place in the contiguous subsequences of $S$ where con occurs $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もしくは右上の雲マークをクリックしてアカウントを作成してください。