Sonya and Exhibition CodeForces - 1004B(水题)

本文介绍了一个关于花卉展览的问题,Sonya希望在一条线上摆放玫瑰和百合,使得来访的每位游客看到的花段中,玫瑰与百合数量乘积之和最大化。通过间隔种植玫瑰和百合,可以实现这一目标。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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 (1n,m1031≤n,m≤103) — the number of flowers and visitors respectively.

Each of the next mm lines contains two integers lili and riri (1lirin1≤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 [13][1…3], there are one rose and two lilies, so the beauty is equal to 12=21⋅2=2;
  • in the segment [24][2…4], there are one rose and two lilies, so the beauty is equal to 12=21⋅2=2;
  • in the segment [25][2…5], there are two roses and two lilies, so the beauty is equal to 22=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 [56][5…6], there are one rose and one lily, so the beauty is equal to 11=11⋅1=1;
  • in the segment [14][1…4], there are two roses and two lilies, so the beauty is equal to 22=42⋅2=4;
  • in the segment [46][4…6], there are two roses and one lily, so the beauty is equal to 21=22⋅1=2.

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


题意:小明家有一个长为n的花园(只有玫瑰花和百合花,且花只能放在整数位置,每个位置放一朵),有m个小朋友来他家参观,每个小朋友将会以li为起点,参观到ri。小朋友获得的愉悦感等同与从l到r的距离里,玫瑰花与百合花数量的乘积。问小明怎样摆放花才能使所以的小朋友获得的愉悦感最大,分别用01表示玫瑰花和百合花。


思路:高中学过,a+b=t,要使a×b最大,那么,a和b应该尽量接近。也就是说,如果a+b=3,那么a=1,b=2,或者b=1,a=2。如果a+b=4,那么a=2,b=2。这样的话,不管小朋友怎么参观,我们只要将玫瑰和百合间隔种植就可以了。


#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++) cout<<(i&1);
    cout<<endl;
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值