首页 技术 正文
技术 2022年11月10日
0 收藏 761 点赞 2,701 浏览 2786 个字

题目链接:http://codeforces.com/contest/1004/problem/B

B. Sonya and Exhibitiontime 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.

Examplesinput

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个游客的访问区间,它可以在每个位置放0或1 ,然后它有一个漂亮程度的方法,在给定的区间里面,0的个数乘以1的个数就是他的漂亮程度,求怎么摆放0 1才能使漂亮程度最高

思路:她给了m个区间,想想一个区间内怎么才能使值是最大的,无非就是0取一半1取一半,这个是肯定得,自己推一个例子就想得到,然后我们就可以进行下一步,要使每个区间得0 1数量各取一半

首先这是一个构造题,答案不唯一,所以一般这种题都是一些考思维性的,一种固定的构造方法,我开始也是去想怎么合并区间,然后发现还是会有影响其他区间的01数,最后仔细的想了下,我无非就是

要每个区间的01数各一半,而且又不影响其他其他区间,我们就可以>V< 010101,这种岔开的排列无论哪个区间肯定会各取一半,这个算是一个思维好题

#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
struct sss
{
int left,right;
}a[];
int main()
{
int n,m;
char str[];
scanf("%d%d",&n,&m);
int l,r;
for(int i=;i<m;i++)
{
scanf("%d%d",&a[i].left,&a[i].right);
}
for(int i=;i<n;i++)
{
if(i%) str[i]='';
else str[i]='';
}
str[n]='\0';
printf("%s",str);
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,991
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,505
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,349
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,134
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,766
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,844