CF1352F.Binary String Reconstruction

普及/提高-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

For some binary string ss (i.e. each character sis_i is either '0' or '1'), all pairs of consecutive (adjacent) characters were written. In other words, all substrings of length 22 were written. For each pair (substring of length 22), the number of '1' (ones) in it was calculated.

You are given three numbers:

  • n0n_0 — the number of such pairs of consecutive characters (substrings) where the number of ones equals 00;
  • n1n_1 — the number of such pairs of consecutive characters (substrings) where the number of ones equals 11;
  • n2n_2 — the number of such pairs of consecutive characters (substrings) where the number of ones equals 22.

For example, for the string s=s="1110011110", the following substrings would be written: "11", "11", "10", "00", "01", "11", "11", "11", "10". Thus, n0=1n_0=1, n1=3n_1=3, n2=5n_2=5.

Your task is to restore any suitable binary string ss from the given values n0,n1,n2n_0, n_1, n_2. It is guaranteed that at least one of the numbers n0,n1,n2n_0, n_1, n_2 is greater than 00. Also, it is guaranteed that a solution exists.

对于某个二进制字符串 ss(即每个字符 sis_i 要么是 '0',要么是 '1'),我们写出其所有相邻(连续)字符对。换言之,我们写出所有长度为 22 的子串。对每个这样的字符对(即长度为 22 的子串),计算其中 '1'(数字 1)的个数。

你将获得三个整数:

  • n0n_0 —— 所有连续字符对(子串)中,含 1 的个数等于 00 的对的数量;
  • n1n_1 —— 所有连续字符对(子串)中,含 1 的个数等于 11 的对的数量;
  • n2n_2 —— 所有连续字符对(子串)中,含 1 的个数等于 22 的对的数量。

例如,对于字符串 s=s = "1110011110",写出的子串依次为:"11"、"11"、"10"、"00"、"01"、"11"、"11"、"11"、"10"。因此,n0=1n_0 = 1,n1=3n_1 = 3,n2=5n_2 = 5。

你的任务是根据给定的 n0,n1,n2n_0, n_1, n_2 恢复出任意一个满足条件的二进制字符串 ss。题目保证 n0,n1,n2n_0, n_1, n_2 中至少有一个大于 00,且解一定存在。

输入格式

The first line contains an integer tt (1≤t≤10001 \le t \le 1000) — the number of test cases in the input. Then test cases follow.

Each test case consists of one line which contains three integers n0,n1,n2n_0, n_1, n_2 (0≤n0,n1,n2≤1000 \le n_0, n_1, n_2 \le 100; n0+n1+n2>0n_0 + n_1 + n_2 \gt 0). It is guaranteed that the answer for given n0,n1,n2n_0, n_1, n_2 exists.

第一行包含一个整数 tt(1≤t≤10001 \le t \le 1000)—— 表示输入中测试用例的数量。随后是各测试用例。

每个测试用例由一行组成,该行包含三个整数 n0,n1,n2n_0, n_1, n_2(0≤n0,n1,n2≤1000 \le n_0, n_1, n_2 \le 100;且 n0+n1+n2>0n_0 + n_1 + n_2 \gt 0)。保证对于给定的 n0,n1,n2n_0, n_1, n_2,答案一定存在。

输出格式

Print tt lines. Each of the lines should contain a binary string corresponding to a test case. If there are several possible solutions, print any of them.

输出 tt 行。每行应包含一个对应于测试用例的二进制字符串。如果存在多种可能的解,输出任意一种即可。

输入输出样例

  • 输入#1

    7
    1 3 5
    1 1 1
    3 9 3
    0 1 0
    3 1 2
    0 0 3
    2 0 0

    输出#1

    1110011110
    0011
    0110001100101011
    10
    0000111
    1111
    000

输入解题思路,AI测评打分。不知道怎么写?

首页