CF1303A.Erasing Zeroes

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given a string ss. Each character is either 0 or 1.

You want all 1's in the string to form a contiguous subsegment. For example, if the string is 0, 1, 00111 or 01111100, then all 1's form a contiguous subsegment, and if the string is 0101, 100001 or 11111111111101, then this condition is not met.

You may erase some (possibly none) 0's from the string. What is the minimum number of 0's that you have to erase?

给你一个字符串 ss,其中每个字符均为 0 或 1。

你希望字符串中所有的 1 构成一个连续的子段。例如,若字符串为 0、1、00111 或 01111100,则所有 1 构成一个连续的子段;而若字符串为 0101、100001 或 11111111111101,则不满足该条件。

你可以从字符串中删除若干个(可能为零个)0。你需要删除的 0 的最小数量是多少?

输入格式

The first line contains one integer tt (1≤t≤1001 \le t \le 100) — the number of test cases.

Then tt lines follow, each representing a test case. Each line contains one string ss (1≤∣s∣≤1001 \le |s| \le 100); each character of ss is either 0 or 1.

第一行包含一个整数 tt(1≤t≤1001 \le t \le 100)—— 表示测试用例的数量。

接下来有 tt 行,每行表示一个测试用例。每行包含一个字符串 ss(1≤∣s∣≤1001 \le |s| \le 100);ss 的每个字符均为 0 或 1。

输出格式

Print tt integers, where the ii-th integer is the answer to the ii-th testcase (the minimum number of 0's that you have to erase from ss).

输出 tt 个整数,其中第 ii 个整数是第 ii 个测试用例的答案(即需要从 ss 中删除的 0 的最小数量)。

输入输出样例

  • 输入#1

    3
    010011
    0
    1111000

    输出#1

    2
    0
    0

说明/提示

In the first test case you have to delete the third and forth symbols from string 010011 (it turns into 0111).

在第一个测试用例中,你需要从字符串 010011 中删除第三个和第四个字符(它将变为 0111)。

输入解题思路,AI测评打分。不知道怎么写?

首页