309528: CF1694A. Creep

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

Description

Creep

题意翻译

请你构造出一个有 $a$ 个 $0$ 和 $b$ 个 $1$ 的字符串,使它的 $0$ 和 $1$ 的个数相差最多的前缀,$0$ 和 $1$ 的个数相差最少。若有多种答案,输出任意一种。多组数据。 **【输入格式】** 先输入数据组数 $t$,然后 $t$ 行,每行两个整数 $a,b$,表示一组数据。 **【输出格式】** 输出 $t$ 行,每行一个字符串,表示一组数据的答案。 **【数据范围】** $1\leq t\leq 1000$ $1\leq a,b\leq 100$ Translate by [庄nnnn额](https://www.luogu.com.cn/user/521592)

题目描述

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.

输入输出格式

输入格式


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.

输出格式


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.

Input

题意翻译

请你构造出一个有 $a$ 个 $0$ 和 $b$ 个 $1$ 的字符串,使它的 $0$ 和 $1$ 的个数相差最多的前缀,$0$ 和 $1$ 的个数相差最少。若有多种答案,输出任意一种。多组数据。 **【输入格式】** 先输入数据组数 $t$,然后 $t$ 行,每行两个整数 $a,b$,表示一组数据。 **【输出格式】** 输出 $t$ 行,每行一个字符串,表示一组数据的答案。 **【数据范围】** $1\leq t\leq 1000$ $1\leq a,b\leq 100$ Translate by [庄nnnn额](https://www.luogu.com.cn/user/521592)

Output

**题目大意:**
构造一个包含 $a$ 个 $0$ 和 $b$ 个 $1$ 的字符串,使得该字符串的所有前缀中,$0$ 和 $1$ 的个数相差的最大值尽可能小。如果有多个答案,输出其中任意一个。题目包含多组数据。

**输入格式:**
第一行输入一个整数 $t$,表示数据组数。接下来 $t$ 行,每行包含两个整数 $a$ 和 $b$,分别表示一组数据中 $0$ 和 $1$ 的个数。

**输出格式:**
输出 $t$ 行,每行一个字符串,表示一组数据的答案。

**数据范围:**
$1 \leq t \leq 1000$
$1 \leq a, b \leq 100$

**题目描述:**
定义一个二进制字符串 $T$ 的分数为其中 $0$ 和 $1$ 的个数之差的绝对值。例如,$T = $ 010001 包含 $4$ 个 $0$ 和 $2$ 个 $1$,所以 $T$ 的分数是 $|4-2| = 2$。

定义一个二进制字符串 $S$ 的怪癖值(creepiness)为其所有前缀中分数的最大值。例如,$S = $ 01001 的怪癖值是 $2$,因为前缀 $S[1 \ldots 4]$ 的分数是 $2$,而其余前缀的分数为 $2$ 或更小。

给定两个整数 $a$ 和 $b$,构造一个包含 $a$ 个 $0$ 和 $b$ 个 $1$ 的二进制字符串,使其怪癖值尽可能小。

**输入输出格式:**
**输入格式:**
第一行包含一个整数 $t$($1 \le t \le 1000$)——测试用例的数量。接下来是每个测试用例的描述。

每个测试用例只有一行,包含两个整数 $a$ 和 $b$($1 \le a, b \le 100$)——分别对应 $0$ 和 $1$ 的数量。

**输出格式:**
对于每个测试用例,输出一个包含 $a$ 个 $0$ 和 $b$ 个 $1$ 的二进制字符串,使其怪癖值尽可能小。如果有多个答案,输出其中任意一个。

**输入输出样例:**
**输入样例 #1:**
```
5
1 1
1 2
5 2
4 5
3 7
```
**输出样例 #1:**
```
10
011
0011000
101010101
0001111111
```

**说明:**
在第一个测试用例中,$S[1 \ldots 1]$ 的分数是 $1$,而 $S[1 \ldots 2]$ 的分数是 $0$。

在第二个测试用例中,最小的可能怪癖值是 $1$,另一个可能的答案是 $101$。

在第三个测试用例中,最小的可能怪癖值是 $3$,另一个可能的答案是 $0001100$。**题目大意:** 构造一个包含 $a$ 个 $0$ 和 $b$ 个 $1$ 的字符串,使得该字符串的所有前缀中,$0$ 和 $1$ 的个数相差的最大值尽可能小。如果有多个答案,输出其中任意一个。题目包含多组数据。 **输入格式:** 第一行输入一个整数 $t$,表示数据组数。接下来 $t$ 行,每行包含两个整数 $a$ 和 $b$,分别表示一组数据中 $0$ 和 $1$ 的个数。 **输出格式:** 输出 $t$ 行,每行一个字符串,表示一组数据的答案。 **数据范围:** $1 \leq t \leq 1000$ $1 \leq a, b \leq 100$ **题目描述:** 定义一个二进制字符串 $T$ 的分数为其中 $0$ 和 $1$ 的个数之差的绝对值。例如,$T = $ 010001 包含 $4$ 个 $0$ 和 $2$ 个 $1$,所以 $T$ 的分数是 $|4-2| = 2$。 定义一个二进制字符串 $S$ 的怪癖值(creepiness)为其所有前缀中分数的最大值。例如,$S = $ 01001 的怪癖值是 $2$,因为前缀 $S[1 \ldots 4]$ 的分数是 $2$,而其余前缀的分数为 $2$ 或更小。 给定两个整数 $a$ 和 $b$,构造一个包含 $a$ 个 $0$ 和 $b$ 个 $1$ 的二进制字符串,使其怪癖值尽可能小。 **输入输出格式:** **输入格式:** 第一行包含一个整数 $t$($1 \le t \le 1000$)——测试用例的数量。接下来是每个测试用例的描述。 每个测试用例只有一行,包含两个整数 $a$ 和 $b$($1 \le a, b \le 100$)——分别对应 $0$ 和 $1$ 的数量。 **输出格式:** 对于每个测试用例,输出一个包含 $a$ 个 $0$ 和 $b$ 个 $1$ 的二进制字符串,使其怪癖值尽可能小。如果有多个答案,输出其中任意一个。 **输入输出样例:** **输入样例 #1:** ``` 5 1 1 1 2 5 2 4 5 3 7 ``` **输出样例 #1:** ``` 10 011 0011000 101010101 0001111111 ``` **说明:** 在第一个测试用例中,$S[1 \ldots 1]$ 的分数是 $1$,而 $S[1 \ldots 2]$ 的分数是 $0$。 在第二个测试用例中,最小的可能怪癖值是 $1$,另一个可能的答案是 $101$。 在第三个测试用例中,最小的可能怪癖值是 $3$,另一个可能的答案是 $0001100$。

加入题单

算法标签: