QOJ.ac

QOJ

時間限制: 2.0 s 記憶體限制: 1024 MB 總分: 100

#9229. 朱丽叶统一 1

统计

如果一个二进制字符串(由 0 和 1 组成)中所有的 1 都构成一个连续的(可能为空)区间,且中间没有 0,我们称该字符串是“统一的”。例如,001111010000 都是统一的字符串。然而,二进制字符串 10100100011 则不是统一的。

Juliet 有一个二进制字符串 $S$,她愿意删除一些字符以使该字符串变得统一。当 Juliet 删除一个字符时,剩余的字符会滑动以填补空缺。

为了使剩余的字符构成一个统一的二进制字符串,最少需要删除多少个字符?

输入格式

输入包含一行,即字符串 $S$ ($1 \le |S| \le 50$, $S_i = \text{'0'}$ 或 $S_i = \text{'1'}$)。

输出格式

输出一个整数,表示删除字符的最少数量。

样例

输入格式 1

00011011001

输出格式 1

2

说明

在字符串 00011011001 中,Juliet 可以删除两个带下划线的字符,从而得到统一的字符串 000111100

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.