cswork / OA打开练习工作台

RubrikOA #1

Count Binary Substrings

估计简单可在线判题

考点(AI 标注)字符串双指针滑窗

Count all contiguous substrings in which the number of 0s equals the number of 1s and that consist of exactly one block of identical characters immediately followed by one block of the other character. Identical content at different positions is counted separately.

输入格式

One line containing a non-empty binary string s. This site adds 1≤|s|≤200000.

输出格式

Output the number of qualifying substrings as an exact decimal integer (an integer type of at least 64 bits is required).

样例 1

输入:

00110011

输出:

6

样例 2

输入:

01

输出:

1

样例 3

输入:

0000

输出:

0