当前位置:网站首页>F. Binary String Reconstruction
F. Binary String Reconstruction
2022-08-10 20:44:00 【秦小咩】
F. Binary String Reconstruction
F. Binary String Reconstruction
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
For some binary string ss (i.e. each character sisi 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:
- n0n0 — the number of such pairs of consecutive characters (substrings) where the number of ones equals 00;
- n1n1 — the number of such pairs of consecutive characters (substrings) where the number of ones equals 11;
- n2n2 — 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=1n0=1, n1=3n1=3, n2=5n2=5.
Your task is to restore any suitable binary string ss from the given values n0,n1,n2n0,n1,n2. It is guaranteed that at least one of the numbers n0,n1,n2n0,n1,n2 is greater than 00. Also, it is guaranteed that a solution exists.
Input
The first line contains an integer tt (1≤t≤10001≤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,n2n0,n1,n2 (0≤n0,n1,n2≤1000≤n0,n1,n2≤100; n0+n1+n2>0n0+n1+n2>0). It is guaranteed that the answer for given n0,n1,n2n0,n1,n2 exists.
Output
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.
Example
input
Copy
7 1 3 5 1 1 1 3 9 3 0 1 0 3 1 2 0 0 3 2 0 0
output
Copy
1110011110 0011 0110001100101011 10 0000111 1111 000
=========================================================================
本来是打算先构造0,再构造01,再构造11的,但是发现这样会有根本无法构造的情况
考虑构造0
0000000000
接下来在两边进行扩展
000000000001
这样就多了一个01
剩余的01全部放在左边
1010101000000000001
剩余的11全部放在右边
10101000000000000001111111111111
这样的构造就能够互不影响
#include<iostream>
#include<cstdio>
#include<cstring>
# include<iomanip>
#include<algorithm>
#define mo 998244353;
using namespace std;
typedef long long int ll;
int main()
{
int t;
cin>>t;
while(t--)
{
int a,b,c;
cin>>a>>b>>c;
string s="";
int check=0;
if(c)
{
for(int i=1;i<=c+1;i++)
{
s+="1";
}
check=1;
}
int flag=1;
if(b)
{
b--;
s=s+"0";
if(!check)
s="1"+s;
flag=0;
}
if(b)
{
for(int i=1;i<=b;i++)
{
if(i%2)
{
s="0"+s;
}
else
{
s="1"+s;
}
}
}
if(a)
{
for(int i=1;i<=a+flag;i++)
{
s+="0";
}
}
cout<<s<<endl;
}
return 0;
}边栏推荐
- 实施MES管理系统前,这三个问题要考虑好
- Introduction to PostgreSQL
- The most complete GIS related software in history (CAD, FME, ArcGIS, ArcGISPro)
- 链表应用----约瑟夫问题
- Getting started with kuberentes Auditing
- CMU博士论文 | 视频多模态学习:探索模型和任务复杂性
- YOLOv3 SPP source analysis
- Kerberos认证
- Rider调试ASP.NET Core时报thread not gc-safe的解决方法
- Auto.js中APP应用相关指令
猜你喜欢

svg+元素js实现在图片上描点成框,并获取相对图片的坐标位置

UE4 - 河流流体插件Fluid Flux

Multifunctional Nanozyme Ag/PANI | Flexible Substrate Nano ZnO Enzyme | Rhodium Sheet Nanozyme | Ag-Rh Alloy Nanoparticle Nanozyme | Iridium Ruthenium Alloy/Iridium Oxide Biomimetic Nanozyme

双 TL431 级联振荡器

深度学习实战教程(一):感知器

数据标注太昂贵?这个方法可以用有限的数据训练模型实现基于文本的ReID!

Pt/CeO2 monatomic nanoparticles enzyme | H - rGO - Pt @ Pd NPs enzyme | carbon nanotube load platinum nanoparticles peptide modified nano enzyme | leukemia antagonism FeOPtPEG composite nano enzyme

Echart饼状图标注遮盖解决方案汇总

mysql----group by、where以及聚合函数需要注意事项

mysql性能监控与执行计划
随机推荐
通用线程:POSIX 线程详解,第 2部分
图扑智慧电力可视化大屏,赋能虚拟电厂精准减碳
社区分享|货拉拉通过JumpServer纳管大规模云上资产
Floating window in Auto.js
Implementation of graceful exit in Golang
ctfshow-osint
[Golang]从0到1写一个web服务(上)
APP application related instructions in Auto.js
Kyligence 通过 SOC 2 Type II 审计,以可信赖的企业级产品服务全球客户
[Golang]如何优雅管理系统中的几十个UDF(API)
PostgreSQL 介绍
(12) findContours function hierarchy explanation
如何提高代码的可读性 学习笔记
链表应用----约瑟夫问题
指针常量和常量指针
数据标注太昂贵?这个方法可以用有限的数据训练模型实现基于文本的ReID!
mysql踩坑----case when then用法
LeetCode questions 1-10
2021年中国工业互联网安全大赛(福建省选拔赛) 暨首届福建省工业互联网创新大赛
Transferrin-modified osthole long-circulating liposomes/PEG-PLGA nanoparticles loaded with notoginsenoside R1 ([email prot