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
Input
7
1 3 5
1 1 1
3 9 3
0 1 0
3 1 2
0 0 3
2 0 0
Output
1110011110
0011
0110001100101011
10
0000111
1111
000
思路:0和2的情况我们可以直接构造出来,但是1的情况,就需要多考虑一下了。
①0和2都存在的情况。
②只有0存在的情况。
③只有2存在的情况。
④0和2都不存在的情况。
找规律分下奇偶,就可以了。具体看代码:

#include<bits/stdc++.h>
#define ll long long
using namespace std;int n0,n1,n2;int main()
{int t;scanf("%d",&t);while(t--){scanf("%d%d%d",&n0,&n1,&n2);string s0="",s1="",s2="";if(n0) s0+='0';if(n2) s2+='1';while(n0>0) s0+='0',n0--;while(n2>0) s2+='1',n2--;if(s0.size()&&s2.size()){if(n1&1) for(int i=1;i<=n1/2;i++) s1+="10";else{for(int i=1;i<n1/2;i++) s1+="10";s2+='0';}}else if(s0.size()){for(int i=1;i<=n1/2;i++) s1+="10";if(n1&1) s0='1'+s0;}else if(s2.size()){for(int i=1;i<=n1/2;i++) s1+="10";if(n1&1) s2=s2+'0';}else{for(int i=1;i<=(n1+1)/2;i++) s1+="10";if(n1%2==0) s1+='1';}cout<<s0<<s1<<s2<<endl;}return 0;
}

努力加油a啊,(o)/~

Binary String Reconstruction CodeForces - 1352F(思维+构造)相关推荐

  1. Binary String Minimizing CodeForces - 1256D(贪心)

    You are given a binary string of length n (i. e. a string consisting of n characters '0' and '1'). I ...

  2. Codeforces Round #624 (Div. 3) E. Construct the Binary Tree 思维 + 构造

    传送门 文章目录 题意: 思路: 题意: 给你n,dn,dn,d,让你构造有nnn个点的二叉树,他们每个节点深度和为ddd. n,d≤3000n,d\le 3000n,d≤3000. 思路: 先考虑不 ...

  3. Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals) C. String Reconstruction 并查集

    C. String Reconstruction 题目连接: http://codeforces.com/contest/828/problem/C Description Ivan had stri ...

  4. 【2019牛客暑期多校训练营(第三场)- B】Crazy Binary String(思维,01串,前缀和)

    题干: 链接:https://ac.nowcoder.com/acm/contest/883/B 来源:牛客网 ZYB loves binary strings (strings that only ...

  5. 中石油训练赛 - Edit Distance(思维+构造)

    题目描述 A binary string is a non-empty sequence of 0's and 1's, e.g., 010110, 1, 11101, etc. The edit d ...

  6. D1. Kirk and a Binary String (easy version)

    题目链接:http://codeforces.com/contest/1204/problem/D1 D1. Kirk and a Binary String (easy version) time ...

  7. 题解 CF1399D 【Binary String To Subsequences】

    题目链接:http://codeforces.com/contest/1399/problem/D 题目描述: You are given a binary string s consisting o ...

  8. 14. Juju and Binary String

    题目链接:Juju and Binary String 感觉这题的思路和代码实现都比 E 题简单,不知道怎么评到的 2700 分. 给你一个长为 nnn 的 01 串,定义其 cuteness 为 1 ...

  9. Juju and Binary String(前缀和)

    Juju and Binary String [Link](Problem - F - Codeforces) 题意 给你一个010101串strstrstr长度为nnn,这个串的权定为onesn(o ...

最新文章

  1. python画小猪乔治_小孩挑食难搞定?试下猪肉这样炒,简单5步超下饭,比牛肉还香嫩...
  2. linux-搜索查找类
  3. Codeforces 164 E Compatible Numbers
  4. PL/SQL Developer 使用技巧小结(转)
  5. 程序员面试的一些注意点
  6. 软件工程资料 - 优秀的大学怎么教程序开发和软件工程课
  7. linux批量过去5小时前文件名,Linux批量修改文件名
  8. ftp linux 服务器 麒麟_阿里云ECS服务器搭建vsftpd
  9. 松下TDA-200开启呼叫转移功能
  10. 如何在Android上查看本地空气质量指数
  11. RAL 2022|基于3D语义共视图的语义SLAM精确回环检测
  12. Cisco *** Client 报错问题
  13. 无线路由器及Wi-Fi组网指南(史上最全)
  14. springboot系列课程笔记-第四章-WEB开发
  15. 可口可乐VS元气森林,谁的酒量更微醺
  16. ES压测工具(一):esrally工具入门与实践
  17. check函数c++
  18. Wamp错误: Forbidden You don't have permission to access / on this server.
  19. 2048版俄罗斯方块java_俄罗斯方块版2048
  20. 河北外国语学院计算机专业好吗,河北外国语学院最好的专业是什么(10大热门专业排名)...

热门文章

  1. java 手动事务回滚_JAVA设置手动提交事务,回滚事务,提交事务的操作
  2. linux启动设置运行级别,Linux的运行级别和设置开机启动服务的方式
  3. win10诊断启动后联网_小技巧:win10网络共享文件夹出现错误无法访问如何解决?...
  4. 微服务的好处与弊端_在云原生时代,就一定要用微服务吗?
  5. QT之QHash简介
  6. Android开发之高德地图定位成功返回的定位信息
  7. 教你实现splash欢迎页面延迟跳转的6种方法
  8. word万维计算机教程,计算机课件word文档.doc
  9. 重庆大学计算机学院就读,唐远炎(计算机学院)老师 - 重庆大学 - 院校大全
  10. bioinformaitcs的latex版本参考文献填坑