B. Sonya and Exhibition
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Sonya decided to organize an exhibition of flowers. Since the girl likes only roses and lilies, she decided that only these two kinds of flowers should be in this exhibition.

There are nn flowers in a row in the exhibition. Sonya can put either a rose or a lily in the ii-th position. Thus each of nn positions should contain exactly one flower: a rose or a lily.

She knows that exactly mm people will visit this exhibition. The ii-th visitor will visit all flowers from lili to riri inclusive. The girl knows that each segment has its own beauty that is equal to the product of the number of roses and the number of lilies.

Sonya wants her exhibition to be liked by a lot of people. That is why she wants to put the flowers in such way that the sum of beauties of all segments would be maximum possible.

Input

The first line contains two integers nn and mm (1≤n,m≤1031≤n,m≤103) — the number of flowers and visitors respectively.

Each of the next mm lines contains two integers lili and riri (1≤li≤ri≤n1≤li≤ri≤n), meaning that ii-th visitor will visit all flowers from lili to ririinclusive.

Output

Print the string of nn characters. The ii-th symbol should be «0» if you want to put a rose in the ii-th position, otherwise «1» if you want to put a lily.

If there are multiple answers, print any.

Examples
input

Copy
5 3
1 3
2 4
2 5
output

Copy
01100
input

Copy
6 3
5 6
1 4
4 6
output

Copy
110010
Note

In the first example, Sonya can put roses in the first, fourth, and fifth positions, and lilies in the second and third positions;

  • in the segment [1…3][1…3], there are one rose and two lilies, so the beauty is equal to 1⋅2=21⋅2=2;
  • in the segment [2…4][2…4], there are one rose and two lilies, so the beauty is equal to 1⋅2=21⋅2=2;
  • in the segment [2…5][2…5], there are two roses and two lilies, so the beauty is equal to 2⋅2=42⋅2=4.

The total beauty is equal to 2+2+4=82+2+4=8.

In the second example, Sonya can put roses in the third, fourth, and sixth positions, and lilies in the first, second, and fifth positions;

  • in the segment [5…6][5…6], there are one rose and one lily, so the beauty is equal to 1⋅1=11⋅1=1;
  • in the segment [1…4][1…4], there are two roses and two lilies, so the beauty is equal to 2⋅2=42⋅2=4;
  • in the segment [4…6][4…6], there are two roses and one lily, so the beauty is equal to 2⋅1=22⋅1=2.

The total beauty is equal to 1+4+2=71+4+2=7.

题意:在一个展览中,有n朵花,可以是玫瑰花,可以是百合花,有m个人,给出他们的观察区间,求出他们观察区间的最大美丽值,美丽值等于观察区间里玫瑰的数量乘以百合的数量。

分析:如果要两个数的乘积最大,那么这两个数要么相等,要么只差1。比如观察区间为(1,4),一共有4朵花,如果玫瑰2朵,百合2朵,乘积为4;如果玫瑰3朵,百合1朵,乘积为3。所以只要让玫瑰和百合的分配变成一朵玫瑰,一朵百合就行。

 #include<cstdio>
int main()
{
int n,m;
while(~scanf("%d %d",&n,&m))
{
int a,b;
for(int i=;i<=m;i++)
scanf("%d %d",&a,&b);
for(int i=;i<=n;i++)
{
if(i%==)
printf("");
else
printf("");
}
printf("\n");
}
return ;
}

Sonya and Exhibition 1004B的更多相关文章

  1. B - Sonya and Exhibition CodeForces - 1004B (思维题)

    B. Sonya and Exhibition time limit per test 1 second memory limit per test 256 megabytes input stand ...

  2. [Codeforces Round495B] Sonya and Exhibition

    [题目链接] https://codeforces.com/contest/1004/problem/B [算法] 不难发现 , 最优解一定是01010101.... 时间复杂度 : O(N) [代码 ...

  3. Sonya and Exhibition

    http://codeforces.com/group/1EzrFFyOc0/contest/1004/problem/B #include<iostream> #include<c ...

  4. Codeforces Round #495 (Div. 2) B

    题目链接:http://codeforces.com/contest/1004/problem/B B. Sonya and Exhibition time limit per test 1 seco ...

  5. cordforce 495 补题 <未完>

    题目链接: http://codeforces.com/contest/1004/my A. Sonya and Hotels 分类讨论 看第一个样例解释的时候没看到后面第二行还有一个19,想了半天为 ...

  6. CodeForces - 1004B

    Sonya decided to organize an exhibition of flowers. Since the girl likes only roses and lilies, she ...

  7. Codeforces713C Sonya and Problem Wihtout a Legend(DP)

    题目 Source http://codeforces.com/problemset/problem/713/C Description Sonya was unable to think of a ...

  8. (01背包变形) Cow Exhibition (poj 2184)

    http://poj.org/problem?id=2184   Description "Fat and docile, big and dumb, they look so stupid ...

  9. Codeforces Round #371 (Div. 2)E. Sonya and Problem Wihtout a Legend[DP 离散化 LIS相关]

    E. Sonya and Problem Wihtout a Legend time limit per test 5 seconds memory limit per test 256 megaby ...

随机推荐

  1. Java泛型深入理解(转载)

    原文地址  http://blog.csdn.net/sunxianghuang/article/details/51982979 泛型之前 在面向对象编程语言中,多态算是一种泛化机制.例如,你可以将 ...

  2. ntp服务问题

    原本国内的主机直接指向阿里云就可以时间同步了  但是国外的主机 却有报错  这个报错还没有解决 1 Oct 03:47:30 ntpdate[20969]: no server suitable fo ...

  3. 头皮溢脂性皮炎推荐联合治疗:采乐50ml+希尔生100g(请看详情页)维生素B2维生素B6

    治疗头皮脂溢性皮炎采乐50ml+希尔生100g联合用药用法:用药先用一般香皂清洗头发及头皮,头皮处于湿润状态,取适量希尔生洗剂涂于头皮表面,充分揉搓出泡沫样5 min后用清水冲净抹干,再将适量采乐洗剂 ...

  4. WebUploader 手机端上传图片(转)

    https://blog.csdn.net/loserorleader/article/details/50395040

  5. (转)驱动程序安装类(C#)

    原文地址:http://www.cnblogs.com/BoyXiao/archive/2011/03/31/2001535.html 回忆刚进公司那会儿,手头的第一个工作就是完成虚拟键盘,也就是通过 ...

  6. Centos配置iptables开放ftp服务

    安装完vsftpd后,默认情况下,CentOS的防火墙是不开放ftp服务的,需要添加模块和开放21端口才能提供ftp访问.1.添加ip_conntrack_ftp 模块[root@hexuweb101 ...

  7. javascript(面向对象,作用域,闭包,设计模式等)

    javascript(面向对象,作用域,闭包,设计模式等) 1. 常用js类定义的方法有哪些? 参考答案:主要有构造函数原型和对象创建两种方法.原型法是通用老方法,对象创建是ES5推荐使用的方法.目前 ...

  8. 安全测试3_Web后端知识学习

    其实中间还应该学习下web服务和数据库的基础,对于web服务大家可以回家玩下tomcat或者wamp等东西,数据库的话大家掌握基本的增删该查就好了,另外最好掌握下数据库的内置函数,如:concat() ...

  9. 压缩(zip)

    默认情况这些压缩工具在压缩后会删除源文件(zip除外):而且默认只压缩文件,而不压缩目录(链接到打包程序). gzip bzip2 zip GNU tar 1.gzip 1.1.压缩 gzip 压缩工 ...

  10. python 读取bin文件

    python读取bin文件并下发串口   # coding:utf-8import time, serialfrom struct import *import binascii file = ope ...