cswork / OA打开练习工作台

DellOA #2

Count Binary Substrings

估计简单可在线判题

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

Count the contiguous substrings in which the numbers of 0s and 1s are equal and each character forms a single contiguous block. Identical text at different positions is counted separately.

输入格式

One line containing a binary string of only 0 and 1. The original upper bound on the length is 100000, and no lower bound is given; this site keeps the empty string (an empty line) as valid.

输出格式

Output a single integer, the answer.

样例 1

输入:

011001

输出:

4

样例 2

输入:

00110011

输出:

6

样例 3

输入:

输出:

0

样例说明

The outputs of the three public examples are, in order: 4; 6; 0. Verified by independent enumeration or direct simulation.