310866: CF1902A. Binary Imbalance

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

A. Binary Imbalancetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

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 $s_i = s_{i+1}$, you insert '1'. If $s_i \neq s_{i+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)?

Input

The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of testcases.

The first line of each testcase contains an integer $n$ ($1 \le n \le 100$).

The second line contains a string $s$ of length exactly $n$, consisting only of characters '0' and/or '1'.

Output

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".

ExampleInput
3
2
00
2
11
2
10
Output
YES
NO
YES
Note

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 $s_1 \neq s_2$, you insert a '0'. The resulting string is "100". It has two zeroes and only a single one, so the answer is "YES".

Output

题目大意:
这是一个关于二进制字符串的题目。给定一个只包含字符 '0' 和 '1' 的字符串 s。你可以进行以下操作:选择字符串 s 的一个位置 i(1 ≤ i < |s|,|s| 是字符串 s 的当前长度),并在第 i 个字符和第 i+1 个字符之间插入一个字符。如果 s_i = s_{i+1},则插入 '1';如果 s_i ≠ s_{i+1},则插入 '0'。问是否可以通过任意次数的操作(可能不进行操作),使得字符串中 '0' 的数量严格大于 '1' 的数量。

输入输出数据格式:
输入:
- 第一行包含一个整数 t(1 ≤ t ≤ 100),表示测试用例的数量。
- 每个测试用例有两行,第一行包含一个整数 n(1 ≤ n ≤ 100),第二行包含一个长度为 n 的字符串 s,只包含字符 '0' 和 '1'。

输出:
- 对于每个测试用例,如果可以通过任意次数的操作使得字符串中 '0' 的数量严格大于 '1' 的数量,则输出 "YES",否则输出 "NO"。

示例:
输入:
```
3
2
00
2
11
2
10
```
输出:
```
YES
NO
YES
```

注意:
- 在第一个测试用例中,字符串中 '0' 的数量已经大于 '1' 的数量。
- 在第二个测试用例中,无法通过插入任何 '0' 来改变字符串。
- 在第三个测试用例中,可以选择 i = 1,在第一个和第二个字符之间插入 '0',得到字符串 "100",其中 '0' 的数量为2,'1' 的数量为1,所以答案为 "YES"。题目大意: 这是一个关于二进制字符串的题目。给定一个只包含字符 '0' 和 '1' 的字符串 s。你可以进行以下操作:选择字符串 s 的一个位置 i(1 ≤ i < |s|,|s| 是字符串 s 的当前长度),并在第 i 个字符和第 i+1 个字符之间插入一个字符。如果 s_i = s_{i+1},则插入 '1';如果 s_i ≠ s_{i+1},则插入 '0'。问是否可以通过任意次数的操作(可能不进行操作),使得字符串中 '0' 的数量严格大于 '1' 的数量。 输入输出数据格式: 输入: - 第一行包含一个整数 t(1 ≤ t ≤ 100),表示测试用例的数量。 - 每个测试用例有两行,第一行包含一个整数 n(1 ≤ n ≤ 100),第二行包含一个长度为 n 的字符串 s,只包含字符 '0' 和 '1'。 输出: - 对于每个测试用例,如果可以通过任意次数的操作使得字符串中 '0' 的数量严格大于 '1' 的数量,则输出 "YES",否则输出 "NO"。 示例: 输入: ``` 3 2 00 2 11 2 10 ``` 输出: ``` YES NO YES ``` 注意: - 在第一个测试用例中,字符串中 '0' 的数量已经大于 '1' 的数量。 - 在第二个测试用例中,无法通过插入任何 '0' 来改变字符串。 - 在第三个测试用例中,可以选择 i = 1,在第一个和第二个字符之间插入 '0',得到字符串 "100",其中 '0' 的数量为2,'1' 的数量为1,所以答案为 "YES"。

加入题单

上一题 下一题 算法标签: