Sonya and Exhibition 1004B

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个人,给出他们的观察区间,求出他们观察区间的最大美丽值,美丽值等于观察区间里玫瑰的数量乘以百合的数量。

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

 1 #include<cstdio>
 2 int main()
 3 {
 4     int n,m;
 5     while(~scanf("%d %d",&n,&m))
 6     {
 7         int a,b;
 8         for(int i=1;i<=m;i++)
 9             scanf("%d %d",&a,&b);
10         for(int i=1;i<=n;i++)
11         {
12             if(i%2==1)
13                 printf("1");
14             else
15                 printf("0");
16         }
17         printf("\n");
18     }
19     return 0;
20 }

 

 

posted on 2018-09-25 10:31  一只小毛球  阅读(193)  评论(0编辑  收藏  举报

导航