IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> C++知识库 -> C. Team -> 正文阅读

[C++知识库]C. Team

Problem - C - Codeforces

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

Copy

1 2

output

Copy

101

input

Copy

4 8

output

Copy

110110110101

input

Copy

4 10

output

Copy

11011011011011

input

Copy

1 5

output

Copy

-1
题意:给一组只有0和1的数组,排序满足条件:

1.两个相邻的零不能在一起

2.三个1不能在一起

#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<cmath>
#include<string.h>
using namespace std;
// ctrl+shift+C 注释
//ctrl+shift+x 取消
#define int long long
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef pair<int,int> PII;
const int N=2e5+10;
const ll M=1e18+10;
const int mod=1e9+7;
int a[N],sum[N];
priority_queue<int,vector<int>,greater<int> >pq;
set<int>se;
map<int,int>mp;
queue<int>qu;
vector<int>v;
deque<int>de;
int n,m;
void solve()
{
    cin>>n>>m;
    if(m>n*2+2||n>m+1)
    {
        cout<<-1<<endl;
        return;
    }
    int f=0;
    if(m==n)// 010101
    {
        for(int i=0;i<n;i++)
        {
            cout<<"10";
        }
    }
    else if(m-n<=2&&m>n)// n=2 m=3 10101
    {
        for(int i=1;i<=n;i++)
        {
            cout<<"10";
        }
        for(int i=1;i<=m-n;i++)
        cout<<"1";
    }
    else if(n-1==m)// n=3 m=2  01010
    {
        for(int i=1;i<=m;i++)
        {
            cout<<"01";
        }
        cout<<0;
    }
    else if(m<n*2)// 0多 n=4 m=7  11011011010
    {
        int res=n*2-m;
        for(int i=1;i<=n-res;i++)
        {
           cout<<"110";
        }
        for(int i=1;i<=res;i++)
        {
            cout<<"10";
        }
    }
   else if(m==n*2)
    {
        for(int i=0;i<n;i++)
        {
            cout<<"110";
        }
    }
    else if(m>n*2&&m<=n*2+2)//1多 n=4 m=9  1101101101101
    {
         for(int i=0;i<n;i++)
         {
             cout<<"110";
         }
         int res=m-n*2;
         for(int i=1;i<=res;i++)
         {
             cout<<1;
         }
    }
    cout<<endl;
}
signed main()
{
   int t=1;
   //cin>>t;
   while(t--)
   {
       solve();
   }
}

  C++知识库 最新文章
【C++】友元、嵌套类、异常、RTTI、类型转换
通讯录的思路与实现(C语言)
C++PrimerPlus 第七章 函数-C++的编程模块(
Problem C: 算法9-9~9-12:平衡二叉树的基本
MSVC C++ UTF-8编程
C++进阶 多态原理
简单string类c++实现
我的年度总结
【C语言】以深厚地基筑伟岸高楼-基础篇(六
c语言常见错误合集
上一篇文章      下一篇文章      查看所有文章
加:2022-10-31 11:35:34  更:2022-10-31 11:40:23 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年5日历 -2024/5/19 6:41:39-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码