a063. SGU 187. Twist and whirl - want to cheat 加强版
Tags :
Accepted rate: 151人/ 169人 ( 89%) [非即時]
評分方式:
Tolerant

最近更新 : 2011-02-26 21:09

Content

A well-known sharper I*** invented a new way to swindle people. There are N thimbles on the table, and there is a small ball with the number under each of them. The balls are numbered with numbers from 1 to N from left to right. At one operation I*** changes the order of some subsequence of successive thimbles to the opposite. Your task is to find the order of numbers (from left to right) in sequence after all of his manipulations. The total number of manipulations is M.

Input

The first line contains two integer numbers N and M (1<=N<=130000, 1<=M<=100000) separated by a space. Each of the following M lines contains two integer numbers Pi, Qi (1<=Pi<=Qi<=N) - positions of the leftmost and rightmost thimbles in rotated sequence.

Output
Output the sequence of N numbers - the numbers of balls in the thimbles from left to right.
Sample Input #1
5 2
1 3
4 5

5 2
1 4
2 5
Sample Output #1
3 2 1 5 4
4 5 1 2 3
測資資訊:
記憶體限制: 512 MB
公開 測資點#0 (100%): 3.0s , <10M
Hint :

SGU187加强,原题M<=2000改为M<=100000。

splay、AVL等的练习题,不卡空间,时限1s。

Tags:
出處:
SGU 187 [管理者: liouzhou_101 (王启圣) ]

Status Forum 排行

ID User Problem Subject Hit Post Date
14426 lltzpp (lltzpp) a063
___嗯
1619 2018-07-16 17:25