cswork / OA打开练习工作台

CanvaOA #3

Counting Binary Substrings (Backend)

估计简单可在线判题

考点(AI 标注)字符串

Count all contiguous substrings that consist of exactly two runs, one of 0s and one of 1s, with equal lengths.

This site's standard I/O format and any supplementary ranges follow this problem's statement.

输入格式

A single line containing a binary string s, 5≤|s|≤500000; characters are only 0/1.

输出格式

Output the number of qualifying substrings.

样例 1

输入:

001101

输出:

4

样例 2

输入:

00110

输出:

3

样例 3

输入:

010101

输出:

5