A16294 | Binary Imbalance
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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)?
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)?
输入格式
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'.
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'.
输出格式
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".
输入输出样例
输入 #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 $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".
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".
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted