CF1902A.Binary Imbalance
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a string s, consisting only of characters '0' and/or '1'.
In one operation, you choose a position i from 1 to ∣s∣−1, where ∣s∣ is the current length of string s. Then you insert a character between the i-th and the (i+1)-st characters of s. If si=si+1, you insert '1'. If si=si+1, you insert '0'.
Is it possible to make the number of zeroes in the string strictly greater than the number of ones, using any number of operations (possibly, none)?
给你一个字符串 s,它仅由字符 '0' 和/或 '1' 组成。
在一次操作中,你选择一个位置 i(其中 i 的取值范围为 1 到 ∣s∣−1,∣s∣ 表示当前字符串 s 的长度),然后在 s 的第 i 个字符与第 (i+1) 个字符之间插入一个字符:若 si=si+1,则插入 '1';若 si=si+1,则插入 '0'。
是否可能通过任意次数的操作(包括零次)使得字符串中 '0' 的个数严格大于 '1' 的个数?
输入格式
The first line contains a single integer t (1≤t≤100) — the number of testcases.
The first line of each testcase contains an integer n (1≤n≤100).
The second line contains a string s of length exactly n, consisting only of characters '0' and/or '1'.
第一行包含一个整数 t(1≤t≤100)——测试用例的数量。
每个测试用例的第一行包含一个整数 n(1≤n≤100)。
第二行包含一个长度恰好为 n 的字符串 s,该字符串仅由字符 '0' 和/或 '1' 组成。
输出格式
For each testcase, print "YES" if it's possible to make the number of zeroes in s strictly greater than the number of ones, using any number of operations (possibly, none). Otherwise, print "NO".
对于每个测试用例,如果可以通过任意次数的操作(可能不进行任何操作)使得字符串 s 中 0 的数量严格大于 1 的数量,则输出 "YES";否则输出 "NO"。
输入输出样例
输入#1
3 2 00 2 11 2 10
输出#1
YES NO YES
说明/提示
In the first testcase, the number of zeroes is already greater than the number of ones.
In the second testcase, it's impossible to insert any zeroes in the string.
In the third testcase, you can choose i=1 to insert a zero between the 1-st and the 2-nd characters. Since s1=s2, you insert a '0'. The resulting string is "100". It has two zeroes and only a single one, so the answer is "YES".
在第一个测试用例中,零的个数已经大于一的个数。
在第二个测试用例中,无法在字符串中插入任何零。
在第三个测试用例中,你可以选择 i=1,在第 1 个字符和第 2 个字符之间插入一个零。由于 s1=s2,你插入一个 '0'。得到的字符串为 "100"。它包含两个零和仅一个一,因此答案是 "YES"。
输入解题思路,AI测评打分。不知道怎么写?