#P16248. [蓝桥杯 2026 省研究生组] 2026 的出现次数

    ID: 18275 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 显示难度普及− 上传者: 标签>动态规划 DP贪心2026蓝桥杯省赛

[蓝桥杯 2026 省研究生组] 2026 的出现次数

Problem Description

You are given a string SS that contains only the digits 00, 22, and 66.

You may perform the following operation any number of times: find a contiguous substring 202202 in the string and replace it with 66.

Your goal is: by performing some operations, make the number of occurrences of the contiguous substring 20262026 in the final string as large as possible.

Now, output this maximum number of occurrences.

Input Format

Input one line containing a string SS consisting only of digits 00, 22, and 66.

Output Format

Output one integer, representing the maximum number of occurrences of the contiguous substring 20262026 in the final string.

2022026
1
2026202202
2

Hint

Constraints

For 40%40\% of the testdata, the length of the string SS, S|S|, satisfies 1S5001 \leq |S| \leq 500.

For all testdata, the length of the string SS, S|S|, satisfies 1S1051 \leq |S| \leq 10^5, and all input characters are restricted to the set {0,2,6}\{0,2,6\}.

Translated by ChatGPT 5