CF776F.Sherlock's bet to Moriarty

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Sherlock met Moriarty for a final battle of wits. He gave him a regular nn sided convex polygon. In addition to it, he gave him certain diagonals to form regions on the polygon. It was guaranteed that the diagonals did not intersect in interior points.

He took each of the region and calculated its importance value. Importance value for a region formed by vertices a1,a2,... ,axa_{1},a_{2},...\ ,a_{x} of the polygon will be given by 2a1+2a2+...+2ax2^{a_{1}}+2^{a_{2}}+...+2^{a_{x}} . Then, he sorted these regions on the basis of their importance value in ascending order. After that he assigned each region an index from 11 to kk , where kk is the number of regions, and index of region is its position in the sorted array calculated above.

He wants Moriarty to color the regions using not more than 2020 colors, such that two regions have same color only if all the simple paths between these two regions have at least one region with color value less than the color value assigned to these regions. Simple path between two regions ff and hh is a sequence of regions r1,r2,... rtr_{1},r_{2},...\ r_{t} such that r1=fr_{1}=f , rt=hr_{t}=h , for each 1<=i<t regions rir_{i} and ri+1r_{i+1} share an edge, and ri=rjr_{i}=r_{j} if and only if i=ji=j .

Moriarty couldn't answer and asks Sherlock to solve it himself. Help Sherlock in doing so.

输入格式

First line contains two integers nn and mm ( 3<=n<=1000003<=n<=100000 , 0<=m<=n30<=m<=n-3 ), the number of vertices in the polygon and the number of diagonals added.

Each of the next mm lines contains two integers aa and bb ( 1<=a,b<=n1<=a,b<=n ), describing a diagonal between vertices aa and bb . It is guaranteed that the diagonals are correct, i. e. aa and bb don't coincide and are not neighboring. It is guaranteed that the diagonals do not intersect.

输出格式

Let the number of regions be kk .

Output kk space-separated integers, each between 11 and 2020 , representing the colors of the regions in the order of increasing importance.

If there are multiple answers, print any of them. It can be shown that at least one answer exists.

输入输出样例

  • 输入#1

    4 1
    1 3
    

    输出#1

    1 2
    
  • 输入#2

    6 3
    1 3
    1 4
    1 5
    

    输出#2

    2 1 2 3
    

说明/提示

In 2nd input, regions formed in order after sorting will be (1,2,3)(1,2,3) , (1,3,4)(1,3,4) , (1,4,5)(1,4,5) , (1,5,6)(1,5,6) , i.e, region (1,2,3)(1,2,3) is first region followed by region (1,3,4)(1,3,4) and so on.

So, we can color regions 11 and 33 with same color, as region number 22 is on the path from 11 to 33 and it has color 11 which is less than color of 11 and 33 , i.e., color number 22 .

首页