加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

CodeForces - 1004B

发布时间:2020-12-14 04:22:30 所属栏目:大数据 来源:网络整理
导读: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 n?flowers in a row in the exhibition. Sonya can put

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?riri?inclusive.

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
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?[13][1…3],there are one rose and two lilies,so the?beauty?is equal to?1?2=21?2=2;
  • in the segment?[24][2…4],so the?beauty?is equal to?1?2=21?2=2;
  • in the segment?[25][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,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?1?1=11?1=1;
  • in the segment?[14][1…4],so the?beauty?is equal to?2?2=42?2=4;
  • in the segment?[46][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.

?

  一种新的思维方式,不是 根据查询要求构造满足查询区间要求的值 ,而是 构造一个完美的序列,使得它对任意的查询,都满足要求。 (不要为了活着而生活,因为生活所以活着)

?

  题目要求的是求一个最大的数,区间中两种不同花的数量的乘积,不难发现,应当尽可能的使区间中两种花的数量都变大,不能让其中一种花的数目很大,而另一种很小,因为这样对一些查询区间是不合适的。为避免这种情况,所以应该是让两种花交替的种植。

?

 1 #include<cstdio>
 2 #include<cstdlib>
 3 #include<cstring>
 4 #include<string>
 5 #include<cmath>
 6 #include<algorithm>
 7 #include<queue>
 8 #include<stack>
 9 #include<deque>
10 #include<map>
11 #include<iostream>
12 using namespace std;
13 typedef long long  LL;
14 const double pi=acos(-1.0);
15 const double e=exp(1);
16 const int N = 10;
17 
18 int main()
19 {
20     int n,m,t;
21     int x,y,i,p,j;
22     scanf("%d%d",&n,&m);
23     for(i=1;i<=m;i++)
24     {
25         scanf("%d%d",&x,&y);
26     }
27     for(i=1;i<=n;i++)
28     {
29         if(i%2)
30             printf("1");
31         else
32             printf("0");
33     }
34     putchar(n);
35     return 0;
36 }
View Code

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读