A15073 | Creep
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Define the score of some binary string $T$ as the absolute difference between the number of zeroes and ones in it. (for example, $T=$ 010001 contains $4$ zeroes and $2$ ones, so the score of $T$ is $|4-2| = 2$ ).
Define the creepiness of some binary string $S$ as the maximum score among all of its prefixes (for example, the creepiness of $S=$ 01001 is equal to $2$ because the score of the prefix $S[1 \ldots 4]$ is $2$ and the rest of the prefixes have a score of $2$ or less).
Given two integers $a$ and $b$ , construct a binary string consisting of $a$ zeroes and $b$ ones with the minimum possible creepiness.
Define the creepiness of some binary string $S$ as the maximum score among all of its prefixes (for example, the creepiness of $S=$ 01001 is equal to $2$ because the score of the prefix $S[1 \ldots 4]$ is $2$ and the rest of the prefixes have a score of $2$ or less).
Given two integers $a$ and $b$ , construct a binary string consisting of $a$ zeroes and $b$ ones with the minimum possible creepiness.
输入格式
The first line contains a single integer $t$ $(1\le t\le 1000)$ — the number of test cases. The description of the test cases follows.
The only line of each test case contains two integers $a$ and $b$ ( $ 1 \le a, b \le 100$ ) — the numbers of zeroes and ones correspondingly.
The only line of each test case contains two integers $a$ and $b$ ( $ 1 \le a, b \le 100$ ) — the numbers of zeroes and ones correspondingly.
输出格式
For each test case, print a binary string consisting of $a$ zeroes and $b$ ones with the minimum possible creepiness. If there are multiple answers, print any of them.
输入输出样例
输入 #1
5 1 1 1 2 5 2 4 5 3 7
输出 #1
10 011 0011000 101010101 0001111111
In the first test case, the score of $S[1 \ldots 1]$ is $1$ , and the score of $S[1 \ldots 2]$ is $0$ .
In the second test case, the minimum possible creepiness is $1$ and one of the other answers is 101.
In the third test case, the minimum possible creepiness is $3$ and one of the other answers is 0001100.
In the second test case, the minimum possible creepiness is $1$ and one of the other answers is 101.
In the third test case, the minimum possible creepiness is $3$ and one of the other answers is 0001100.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted