Skip to content

ledutu/algorithm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

algorithm

A well-known crook has devised a method to deceive people. There are N bowls Make a horizontal row on the table, and under each bowl there is a small ball. These balls numbered 1 to N from left to right. One of his actions will reverse the order of one consecutive octets, for example 2,3,4,5 to 5,4,3,2. After he does M such manipulation, you need to Find the number of N balls under N bowls in left to right order.

Input:

The first line contains two integers N and M (1 <= N <= 100000, 1 <= M <= 100000). Each line in M lines continues The following contains 2 integers Pi, Qi (1 <= Pi <= Qi <= N) - the position of the left and rightmost bowl in the row consecutive reversal.

output:

Print out N integers on a line showing the number of N balls in the order from left to right.

Test case:

Input:

Test #1

5 2

1 3

4 5

Test #2

5 2

1 4

2 5

Output:

Test #1

3 2 1 5 4

Test #2 D

4 5 1 2 3

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages