B. Sonya and Exhibition

点击打开链接

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 ( 1n,m103

) — the number of flowers and visitors respectively.

Each of the next m

lines contains two integers li and ri ( 1lirin), meaning that i-th visitor will visit all flowers from li to ri

inclusive.

Output

Print the string of n

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
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]
, there are one rose and two lilies, so the beauty is equal to 12=2
; in the segment [24], there are one rose and two lilies, so the beauty is equal to 12=2; in the segment [25], there are two roses and two lilies, so the beauty is equal to 22=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 [56]
, there are one rose and one lily, so the beauty is equal to 11=1; in the segment [14], there are two roses and two lilies, so the beauty is equal to 22=4; in the segment [46], there are two roses and one lily, so the beauty is equal to 21=2
  • .

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

.还是自己的脑子不够用,看到最大值,自己明白应该是让每一段都是 数量是相等的,但是还有一个排列的问题,然后自己就蒙了,然而还是B题,自己的思维还是不够大胆,所以应该再想一下,直接1010 排列,就全都ok了,那就不应该出现下面的m段,太唬人了

#include <bits/stdc++.h>

using namespace std;

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


猜你喜欢

转载自blog.csdn.net/qq_36424540/article/details/81032302