time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
For some binary string s (i.e. each character si is either ‘0’ or ‘1’), all pairs of consecutive (adjacent) characters were written. In other words, all substrings of length 2 were written. For each pair (substring of length 2), the number of ‘1’ (ones) in it was calculated.
You are given three numbers:
n0 — the number of such pairs of consecutive characters (substrings) where the number of ones equals 0;
n1 — the number of such pairs of consecutive characters (substrings) where the number of ones equals 1;
n2 — the number of such pairs of consecutive characters (substrings) where the number of ones equals 2.
For example, for the string s=“1110011110”, the following substrings would be written: “11”, “11”, “10”, “00”, “01”, “11”, “11”, “11”, “10”. Thus, n0=1, n1=3, n2=5.
Your task is to restore any suitable binary string s from the given values n0,n1,n2. It is guaranteed that at least one of the numbers n0,n1,n2 is greater than 0. Also, it is guaranteed that a solution exists.
Input
The first line contains an integer t (1≤t≤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,n2 (0≤n0,n1,n2≤100; n0+n1+n2>0). It is guaranteed that the answer for given n0,n1,n2 exists.
Output
Print t 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.
Example
inputCopy
7
1 3 5
1 1 1
3 9 3
0 1 0
3 1 2
0 0 3
2 0 0
outputCopy
1110011110
0011
0110001100101011
10
0000111
1111
000
模板:((01)个数为偶数print(“1”))0区(print(“0”)没有01区时为原数+1)01区(print(“01”)子序列个数为2*n-1(n为01个数))1区(print(“1”)没有01区时为原数+1)
#include<iostream>
#include<cmath>
#include<set>
#include<cstring>
using namespace std;
typedef long long ll;
set<int> sss;
int main()
{
int n;
cin>>n;
while(n--){
int as,bs,cs,am,bm,cm;
scanf("%d%d%d",&as,&bs,&cs);
if(bs==0){if(as)as++;if(cs)cs++;}
int k=(bs+1)/2;
if(bs&&!(bs&1))
cout<<1;
for(int i=1;i<=as;i++)
cout<<0;
//if(bs||as)
//cout<<0;
for(int i=1;i<=k;i++)
cout<<"01";
for(int i=1;i<=cs;i++)
cout<<1;
cout<<endl;
}
}