1003B.md (1433B)
1 Source: https://codeforces.com/problemset/problem/1003/B 2 3 B. Binary String Constructing 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 You are given three integers $a$, $b$ and $x$. Your task is to construct a binary string $s$ of length $n = a + b$ such that there are exactly $a$ zeroes, exactly $b$ ones and exactly $x$ indices $i$ (where $1 \le i \lt n$) such that $s_i \ne s_{i + 1}$. It is guaranteed that the answer always exists. 22 23 For example, for the string "01010" there are four indices $i$ such that $1 \le i \lt n$ and $s_i \ne s_{i + 1}$ ($i = 1, 2, 3, 4$). For the string "111001" there are two such indices $i$ ($i = 3, 5$). 24 25 Recall that binary string is a non-empty sequence of characters where each character is either 0 or 1. 26 27 Input 28 29 The first line of the input contains three integers $a$, $b$ and $x$ ($1 \le a, b \le 100, 1 \le x \lt a + b)$. 30 31 Output 32 33 Print only one string $s$, where $s$ is any binary string satisfying conditions described above. It is guaranteed that the answer always exists. 34 35 Examples 36 37 Input 38 39 ``` 40 2 2 1 41 ``` 42 43 Output 44 45 ``` 46 1100 47 ``` 48 49 Input 50 51 ``` 52 3 3 3 53 ``` 54 55 Output 56 57 ``` 58 101100 59 ``` 60 61 Input 62 63 ``` 64 5 3 6 65 ``` 66 67 Output 68 69 ``` 70 01010100 71 ``` 72 73 Note 74 75 All possible answers for the first example: 76 77 * 1100; 78 * 0011. 79 80 All possible answers for the second example: 81 82 * 110100; 83 * 101100; 84 * 110010; 85 * 100110; 86 * 011001; 87 * 001101; 88 * 010011; 89 * 001011.