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

Sonya计划举办一场只有玫瑰和百合的花卉展览。她需要在n个位置放置花朵,每个位置只能放一朵。每位参观者会查看一段连续的花朵,该段的美感是玫瑰和百合数量的乘积。目标是最大化所有参观者段落的美感总和。通过使0(代表玫瑰)和1(代表百合)交替出现,可以确保美感最大化。
摘要由CSDN通过智能技术生成

题目链接:

http://codeforces.com/problemset/problem/1004/B

题目:

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 n flowers in a row in the exhibition. Sonya can put either a rose or a lily in the i-th position. Thus each of n positions should contain exactly one flower: a rose or a lily.

She knows that exactly m people will visit this exhibition. The i-th visitor will visit all flowers from li to ri 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 n and m (1≤n,m≤1e3) — the number of flowers and visitors respectively.

Each of the next m lines contains two integers li and ri (1≤li≤ri≤n), meaning that i-th visitor will visit all flowers from li to ri inclusive.

Output

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

If there are multiple answers, print any.

Examples

Input

5 3
1 3
2 4
2 5

Output

01100

Input

6 3
5 6
1 4
4 6

Output

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], there are one rose and two lilies, so the beauty is equal to 1⋅2=2;
  • in the segment [2…4], there are one rose and two lilies, so the beauty is equal to 1⋅2=2;
  • in the segment [2…5], there are two roses and two lilies, so the beauty is equal to 2⋅2=4.

The total beauty is equal to 2+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], there are one rose and one lily, so the beauty is equal to 1⋅1=1;
  • in the segment [1…4], there are two roses and two lilies, so the beauty is equal to 2⋅2=4;
  • in the segment [4…6], there are two roses and one lily, so the beauty is equal to 2⋅1=2.

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

题目大意:

有一排n个格子,每个格子里能放一种花,一共有两种花,一种用 0 代表,另一种用 1 代表,然后给你m各区间,每个区间的价值就是这个区间内的两种花的数量之积。问你应该怎么放花,使得这些区间的价值和最大。

分析:

题目的意思转化一下,就是说让0 1 的个数在各个区间内都是接近的(和相等,越接近,积越大),也就是说0 1 分布均匀,那么,我们直接0 1 交替输出,就可以保证0 1 在各个区间都是最接近的。

代码:

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	int l,r;
	for(int i=1;i<=m;i++)
		scanf("%d%d",&l,&r);
	for(int i=0;i<n;i++)
		printf("%d",i%2);
	putchar('\n');
	return 0;
}

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值