Team

CodeForces - 401C

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

sol:这还是挺好构造的吧(虽然我挂的很惨惨惨惨惨惨惨)
如果1比0的两倍还多3个或者0比1多2个就GG了,否则就一定能构造出来
如果1比0多就先用110,再用10
如果0比1多就一直用010101,最后来个0
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
inline ll read()
{
ll s=;
bool f=;
char ch=' ';
while(!isdigit(ch))
{
f|=(ch=='-'); ch=getchar();
}
while(isdigit(ch))
{
s=(s<<)+(s<<)+(ch^); ch=getchar();
}
return (f)?(-s):(s);
}
#define R(x) x=read()
inline void write(ll x)
{
if(x<)
{
putchar('-'); x=-x;
}
if(x<)
{
putchar(x+''); return;
}
write(x/);
putchar((x%)+'');
return;
}
#define W(x) write(x),putchar(' ')
#define Wl(x) write(x),putchar('\n')
int n,m; //n个0,m个1
int main()
{
R(n); R(m);
if(m-n*>) return *puts("-1");
if(n-m>) return *puts("-1");
if(m>=n)
{
while(m>n&&n)
{
putchar(''); putchar(''); putchar('');
m-=; n--;
}
if(n==)
{
while(m--) putchar('');
}
else
{
while(m--)
{
putchar(''); putchar('');
}
}
}
else
{
while(m--)
{
putchar(''); putchar('');
}
putchar('');
}
return ;
}
/*
input
1 2
output
101 input
4 8
output
110110110101 input
4 10
output
11011011011011 input
1 5
output
-1
*/
 

codeforces401C的更多相关文章

随机推荐

  1. Java消息队列——JMS概述

    一.什么是JMS JMS即Java消息服务(Java Message Service)应用程序接口,是一个Java平台中关于面向消息中间件(MOM)的API,用于在两个应用程序之间,或分布式系统中发送 ...

  2. Vue-插槽学习

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. ODPS-Java-SDK快速入门

    一.简介 核心接口包括:AliyunAccount,MaxCompute(SDK中使用原名ODPS)等常见对象组件 更多参见文档:https://help.aliyun.com/document_de ...

  4. Java多线程学习(三)---线程的生命周期

    线程生命周期 摘要: 当线程被创建并启动以后,它既不是一启动就进入了执行状态,也不是一直处于执行状态.在线程的生命周期中,它要经过新建(New).就绪(Runnable).运行(Running).阻塞 ...

  5. 在Winform开发中使用FastReport创建报表

    FastReport.Net是一款适用于Windows Forms, ASP.NET和MVC框架的功能齐全的报表分析解决方案.可用在Microsoft Visual Studio 2005到2015, ...

  6. AtCoder Beginner Contest 053

    D - Card Eater Time limit : 2sec / Memory limit : 256MB Score : 400 points Problem Statement Snuke h ...

  7. redis中的hash、列表、集合操作

    一.hash操作 数据结构:key:{k1:v1, k2:v2, k3:v3} 类似Python中的字典 如:info : {name: lina, age: 22, sex: F} hset key ...

  8. 福州大学软件工程1816 | W班 第3次作业成绩排名

    写在前面 汇总成绩排名链接 1.作业链接 第三次作业--原型设计(结对第一次) 2.评分准则 本次作业总分 25分,由以下部分组成: (1)在随笔开头请加上该博客链接,以方便阅读时查看作业需求,并备注 ...

  9. gethostbyname用法

    //会优先查询解析%windir%\system32\drivers\etc\hosts中静态dns表 //一个域名可对应多个IP hostent->h_addr_list ==> 是in ...

  10. Idea批量修改变量名

    Idea批量修改变量名.在变量名上进行rename操作,所有的同名变量都会自动更改. 快捷键:ALT+SHIFT+R