A11951 | Sonya and Exhibition
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 $l_i$ to $r_i$ 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.
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 $l_i$ to $r_i$ 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.
输入格式
The first line contains two integers $n$ and $m$ ( $1\leq n, m\leq 10^3$ ) — the number of flowers and visitors respectively.
Each of the next $m$ lines contains two integers $l_i$ and $r_i$ ( $1\leq l_i\leq r_i\leq n$ ), meaning that $i$ -th visitor will visit all flowers from $l_i$ to $r_i$ inclusive.
Each of the next $m$ lines contains two integers $l_i$ and $r_i$ ( $1\leq l_i\leq r_i\leq n$ ), meaning that $i$ -th visitor will visit all flowers from $l_i$ to $r_i$ inclusive.
输出格式
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.
If there are multiple answers, print any.
输入输出样例
输入 #1
5 3 1 3 2 4 2 5
输出 #1
01100
输入 #2
6 3 5 6 1 4 4 6
输出 #2
110010
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\ldots3]$ , there are one rose and two lilies, so the beauty is equal to $1\cdot 2=2$ ;
- in the segment $[2\ldots4]$ , there are one rose and two lilies, so the beauty is equal to $1\cdot 2=2$ ;
- in the segment $[2\ldots5]$ , there are two roses and two lilies, so the beauty is equal to $2\cdot 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\ldots6]$ , there are one rose and one lily, so the beauty is equal to $1\cdot 1=1$ ;
- in the segment $[1\ldots4]$ , there are two roses and two lilies, so the beauty is equal to $2\cdot 2=4$ ;
- in the segment $[4\ldots6]$ , there are two roses and one lily, so the beauty is equal to $2\cdot 1=2$ .
The total beauty is equal to $1+4+2=7$ .
- in the segment $[1\ldots3]$ , there are one rose and two lilies, so the beauty is equal to $1\cdot 2=2$ ;
- in the segment $[2\ldots4]$ , there are one rose and two lilies, so the beauty is equal to $1\cdot 2=2$ ;
- in the segment $[2\ldots5]$ , there are two roses and two lilies, so the beauty is equal to $2\cdot 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\ldots6]$ , there are one rose and one lily, so the beauty is equal to $1\cdot 1=1$ ;
- in the segment $[1\ldots4]$ , there are two roses and two lilies, so the beauty is equal to $2\cdot 2=4$ ;
- in the segment $[4\ldots6]$ , there are two roses and one lily, so the beauty is equal to $2\cdot 1=2$ .
The total beauty is equal to $1+4+2=7$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted