C. Team
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Now it's time of Olympiads. Vanya and Egor decided to make his own team to take part in a programming Olympiad. They've been best friends ever since primary school and hopefully, that can somehow help them in teamwork.

For each team Olympiad, Vanya takes his play cards with numbers. He takes only the cards containing numbers 1 and 0. The boys are very superstitious. They think that they can do well at the Olympiad if they begin with laying all the cards in a row so that:

  • there wouldn't be a pair of any side-adjacent cards with zeroes in a row;
  • there wouldn't be a group of three consecutive cards containing numbers one.

Today Vanya brought n cards with zeroes and m cards with numbers one. The number of cards was so much that the friends do not know how to put all those cards in the described way. Help them find the required arrangement of the cards or else tell the guys that it is impossible to arrange cards in such a way.

Input

The first line contains two integers: n (1 ≤ n ≤ 106) — the number of cards containing number 0; m (1 ≤ m ≤ 106) — the number of cards containing number 1.

Output

In a single line print the required sequence of zeroes and ones without any spaces. If such sequence is impossible to obtain, print -1.

Examples
input
1 2
output
101
input
4 8
output
110110110101
input
4 10
output
11011011011011
input
1 5
output
-1

题意:构造一个序列0连续1个 1连续最多两个

先考虑无解,然后需要110,然后10,最后1收尾
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m,l;
int main(int argc, const char * argv[]) {
scanf("%d%d",&n,&m);
if(n->m||*n<m-) {printf("-1");return ;} if(m==n-) printf(""),l=m;
else if(m==n) l=m;
else{
int t=m-n-;
for(int i=;i<=t;i++) printf(""),m-=,n--;
l=min(m,n);
}
for(int i=;i<=l;i++) printf(""),n--,m--;
while(m) printf(""),m--;
return ;
}
 

Codeforces 410C.Team[构造]的更多相关文章

  1. codeforces 932E Team Work(组合数学、dp)

    codeforces 932E Team Work 题意 给定 \(n(1e9)\).\(k(5000)\).求 \(\Sigma_{x=1}^{n}C_n^xx^k\). 题解 解法一 官方题解 的 ...

  2. Codeforces 932E Team work 【组合计数+斯特林数】

    Codeforces 932E Team work You have a team of N people. For a particular task, you can pick any non-e ...

  3. codeforces 1041 e 构造

    Codeforces 1041 E 构造题. 给出一种操作,对于一棵树,去掉它的一条边.那么这颗树被分成两个部分,两个部分的分别的最大值就是这次操作的答案. 现在给出一棵树所有操作的结果,问能不能构造 ...

  4. CodeForces - 401C Team(简单构造)

    题意:要求构造一个字符串,要求不能有连续的两个0在一起,也不能有连续的三个1在一起. 分析: 1.假设有4个0,最多能构造的长度为11011011011011,即10个1,因此若m > (n + ...

  5. URAL 1779 F - The Great Team 构造

    F - The Great TeamTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest ...

  6. codeforces 757F Team Rocket Rises Again

    链接:http://codeforces.com/problemset/problem/757/F 正解:灭绝树. mdzz倍增lca的根节点深度必须是1..我因为这个错误调了好久. 我们考虑先求最短 ...

  7. codeforces C. Team 解题报告

    题目链接:http://codeforces.com/problemset/problem/401/C 题目意思:给出0和1的数目(分别为n和m个),问是否能构造一条同时满足连续两个0不能再一起和连续 ...

  8. Codeforces - 474D - Flowers - 构造 - 简单dp

    https://codeforces.com/problemset/problem/474/D 这道题挺好的,思路是这样. 我们要找一个01串,其中0的段要被划分为若干个连续k的0. 我们设想一个长度 ...

  9. Codeforces Global Round 8 B. Codeforces Subsequences(构造)

    题目链接:https://codeforces.com/contest/1368/problem/B 题意 构造最短的至少含有 $k$ 个 $codeforces$ 子序列的字符串. 题解 如下表: ...

随机推荐

  1. Web数据持久化存储IndexedDB(不常用)

    IndexedDB是在浏览器中保存结构化数据的一种数据库,为了替换WebSQL(标准已废弃,但被广泛支持)而出现.IndexedDB使用NoSQL的形式来操作数据库,保存和读取是JavaScript对 ...

  2. Struts2详细教程

    Struts2详细教程:http://www.yiibai.com/struts_2/

  3. 《The Linux Command Line》 读书笔记03 ls命令与长格式输出解释 文件权限

    ls命令与长格式输出解释 文件权限 ls命令 ls 命令用于列出目录内容,不带参数时列出当前工作目录的内容,也可以指定目标目录(可以指定多个),列出目标目录下的内容. ls命令的参数 ls -l 长格 ...

  4. 不用画线 设置UITableView的全屏分隔线

    如图  添加如下代码 sTableView.separatorInset = UIEdgeInsetsZero; sTableView.layoutMargins = UIEdgeInsetsZero ...

  5. 【读书笔记】iOS-数据交换格式

    数据交换格式主要分为:纯文本格式,XML格式和JSON格式. 一,XML数据交换格式. 多年来,一直在各种计算机语言之间使用.它是老牌的,经典的,灵活的数据交换方式. 1,文档结构. 2,XML文档解 ...

  6. 【读书笔记】iOS网络-保护网络传输

    一,验证服务器通信. 二,HTTP认证. 手机银行应用有两种认证模式:标准验证与快速验证.标准验证只是提示用户输入用户名与密码,而快速验证则让用户注册设备,然后使用PIN进行验证,每次验证时无需用户名 ...

  7. android 界面设计基本知识Ⅲ

    本章继续讲述在android界面设计中相关的知识点.介绍内容包括BroadcastReceiver(广播),Service(服务),Widget(小部件),WebView(网页加载控件). 1.Bro ...

  8. __block和__weak的区别

    API Reference对__block变量修饰符有如下几处解释: //A powerful feature of blocks is that they can modify variables ...

  9. 详解DB2 sqlstate 57016 原因码 "7"错误

  10. The JSP specification requires that an attribute name is preceded by whitespace

    一个jsp页面在本地运行一点问题没有,发布到服务器就报错了: The JSP specification requires that an attribute name is preceded by ...