Sonya and Exhibition 1004B

时间:2021-07-12 09:08:11
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 (1≤n,m≤1031≤n,m≤103) — the number of flowers and visitors respectively.

Each of the next mm lines contains two integers lili and riri (1≤li≤ri≤n1≤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 [1…3][1…3], there are one rose and two lilies, so the beauty is equal to 1⋅2=21⋅2=2;
  • in the segment [2…4][2…4], there are one rose and two lilies, so the beauty is equal to 1⋅2=21⋅2=2;
  • in the segment [2…5][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, fourth, and sixth positions, and lilies in the first, second, and fifth positions;

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

题意:在一个展览中,有n朵花,可以是玫瑰花,可以是百合花,有m个人,给出他们的观察区间,求出他们观察区间的最大美丽值,美丽值等于观察区间里玫瑰的数量乘以百合的数量。

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

 #include<cstdio>
int main()
{
int n,m;
while(~scanf("%d %d",&n,&m))
{
int a,b;
for(int i=;i<=m;i++)
scanf("%d %d",&a,&b);
for(int i=;i<=n;i++)
{
if(i%==)
printf("");
else
printf("");
}
printf("\n");
}
return ;
}

Sonya and Exhibition 1004B的更多相关文章

  1. B - Sonya and Exhibition CodeForces - 1004B &lpar;思维题&rpar;

    B. Sonya and Exhibition time limit per test 1 second memory limit per test 256 megabytes input stand ...

  2. &lbrack;Codeforces Round495B&rsqb; Sonya and Exhibition

    [题目链接] https://codeforces.com/contest/1004/problem/B [算法] 不难发现 , 最优解一定是01010101.... 时间复杂度 : O(N) [代码 ...

  3. Sonya and Exhibition

    http://codeforces.com/group/1EzrFFyOc0/contest/1004/problem/B #include<iostream> #include<c ...

  4. Codeforces Round &num;495 &lpar;Div&period; 2&rpar; B

    题目链接:http://codeforces.com/contest/1004/problem/B B. Sonya and Exhibition time limit per test 1 seco ...

  5. cordforce 495 补题 &lt&semi;未完&gt&semi;

    题目链接: http://codeforces.com/contest/1004/my A. Sonya and Hotels 分类讨论 看第一个样例解释的时候没看到后面第二行还有一个19,想了半天为 ...

  6. CodeForces - 1004B

    Sonya decided to organize an exhibition of flowers. Since the girl likes only roses and lilies, she ...

  7. Codeforces713C Sonya and Problem Wihtout a Legend(DP)

    题目 Source http://codeforces.com/problemset/problem/713/C Description Sonya was unable to think of a ...

  8. &lpar;01背包变形&rpar; Cow Exhibition (poj 2184)

    http://poj.org/problem?id=2184   Description "Fat and docile, big and dumb, they look so stupid ...

  9. Codeforces Round &num;371 &lpar;Div&period; 2&rpar;E&period; Sonya and Problem Wihtout a Legend&lbrack;DP 离散化 LIS相关&rsqb;

    E. Sonya and Problem Wihtout a Legend time limit per test 5 seconds memory limit per test 256 megaby ...

随机推荐

  1. 去除多余的cell 和最后一行cell显示顶头底线

    去除多余cell YourTableview.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero]; 最后一行cell底线顶头显示 s ...

  2. 工作框架各种使用整理 -- 展示数据列表并做update

    <!--ProductCategory.xml--> <?xml version="1.0" encoding="UTF-8"?> &l ...

  3. JS-009-屏幕分辨率、浏览器显示区域、元素位置获取

    此文简略讲述有关屏幕大小.元素位置及大小获取. 执行文中脚本时,请先打开 Chrome 浏览器,并切换至开发者工具的控制台,并打开网址:http://www.yixun.com/,文中元素事例为页面元 ...

  4. hdu------&lpar;4300&rpar;Clairewd’s message&lpar;kmp&rpar;

    Clairewd’s message Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  5. phpcmsV9中表单向导在js调用里日期控件在IE下报Calendar未定义的解决办法

    最近在phpcmsV9里用表单向导弄个的提交表单,但用了日期和时间类型时,用   <script language='javascript' src='{APP_PATH}index.php?m ...

  6. POJ 2540 Hotter Colder

    http://poj.org/problem?id=2540 题意:给你每次行走的路径,而且告诉你每次离一个点光源是远了还是近了,要求每次光源可能存在的位置的面积. 思路:如果出现"same ...

  7. IDEA 15 社区版 Maven项目 启动Tomcat调试

    1.在pom下添加Tomcat插件: <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifac ...

  8. IE 不兼容 js indexOf 函数

      在使用 js 判断数组中是否存储该元素,我们会用到 indexOf 函数.而在 IE 上 indexOf 函数 无法兼容,通过以下方法解决,仅以文章记录一下 if (!Array.prototyp ...

  9. webpack 4&period;0 中 clean-webpack-plugin 的使用

    其实 clean-webpack-plugin 很容易知道它的作用,就是来清除文件的. 一般这个插件是配合 webpack -p 这条命令来使用,就是说在为生产环境编译文件的时候,先把 build或d ...

  10. PTA——支票面额

    PTA 7-38 支票面额 #include<stdio.h> int main() { int n,f,y; ; scanf("%d",&n); ; flag ...