CF1004B.Sonya and Exhibition

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 lil_i to rir_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.

索尼娅决定举办一场花卉展览。由于她只喜欢玫瑰和百合,因此她决定展览中只摆放这两种花卉。

展览中共有 nn 朵花排成一排。索尼娅可以在第 ii 个位置放置一朵玫瑰或一朵百合。因此,这 nn 个位置中的每一个都必须恰好放置一朵花:要么是玫瑰,要么是百合。

她知道将恰好有 mm 位参观者前来参观该展览。第 ii 位参观者将参观从第 lil_i 朵到第 rir_i 朵(含端点)的所有花卉。索尼娅知道,每个区间的“美感”等于该区间内玫瑰的数量与百合的数量的乘积。

索尼娅希望自己的展览受到尽可能多参观者的喜爱。因此,她希望以某种方式摆放花卉,使得所有区间美感之和达到最大可能值。

输入格式

The first line contains two integers nn and mm (1≤n,m≤1031\leq n, m\leq 10^3) — the number of flowers and visitors respectively.

Each of the next mm lines contains two integers lil_i and rir_i (1≤li≤ri≤n1\leq l_i\leq r_i\leq n), meaning that ii-th visitor will visit all flowers from lil_i to rir_i inclusive.

第一行包含两个整数 nn 和 mm(1≤n,m≤1031\leq n, m\leq 10^3),分别表示花朵的数量和游客的数量。

接下来的 mm 行中,每行包含两个整数 lil_i 和 rir_i(1≤li≤ri≤n1\leq l_i\leq r_i\leq n),表示第 ii 位游客将参观从第 lil_i 朵到第 rir_i 朵(含端点)的所有花朵。

输出格式

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.

输出一个长度为 nn 的字符串。其中第 ii 个字符应为 «0»,表示你想在第 ii 个位置放置一朵玫瑰;否则为 «1»,表示你想在第 ii 个位置放置一株百合。

如果存在多个正确答案,输出任意一个即可。

输入输出样例

  • 输入#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…3][1\ldots3], there are one rose and two lilies, so the beauty is equal to 1⋅2=21\cdot 2=2;
  • in the segment [2…4][2\ldots4], there are one rose and two lilies, so the beauty is equal to 1⋅2=21\cdot 2=2;
  • in the segment [2…5][2\ldots5], there are two roses and two lilies, so the beauty is equal to 2⋅2=42\cdot 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\ldots6], there are one rose and one lily, so the beauty is equal to 1⋅1=11\cdot 1=1;
  • in the segment [1…4][1\ldots4], there are two roses and two lilies, so the beauty is equal to 2⋅2=42\cdot 2=4;
  • in the segment [4…6][4\ldots6], there are two roses and one lily, so the beauty is equal to 2⋅1=22\cdot 1=2.

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

在第一个例子中,索尼娅可以在第 1、第 4 和第 5 个位置放置玫瑰,在第 2 和第 3 个位置放置百合;

  • 在区间 [1…3][1\ldots3] 中,有 1 朵玫瑰和 2 朵百合,因此美观度为 1⋅2=21\cdot 2=2;
  • 在区间 [2…4][2\ldots4] 中,有 1 朵玫瑰和 2 朵百合,因此美观度为 1⋅2=21\cdot 2=2;
  • 在区间 [2…5][2\ldots5] 中,有 2 朵玫瑰和 2 朵百合,因此美观度为 2⋅2=42\cdot 2=4。

总美观度为 2+2+4=82+2+4=8。

在第二个例子中,索尼娅可以在第 3、第 4 和第 6 个位置放置玫瑰,在第 1、第 2 和第 5 个位置放置百合;

  • 在区间 [5…6][5\ldots6] 中,有 1 朵玫瑰和 1 朵百合,因此美观度为 1⋅1=11\cdot 1=1;
  • 在区间 [1…4][1\ldots4] 中,有 2 朵玫瑰和 2 朵百合,因此美观度为 2⋅2=42\cdot 2=4;
  • 在区间 [4…6][4\ldots6] 中,有 2 朵玫瑰和 1 朵百合,因此美观度为 2⋅1=22\cdot 1=2。

总美观度为 1+4+2=71+4+2=7。

输入解题思路,AI测评打分。不知道怎么写?

首页