QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 512 MB Total points: 100

#21403. 文艺平衡树

統計

这是一道模板题。

您需要写一种数据结构(可参考题目标题),来维护一个序列,其中需要提供以下操作:

翻转一个区间,例如原有序序列是 5 4 3 2 1,翻转区间是 $ [2, 4] $ 的话,结果是 5 2 3 4 1

Input

第一行为 $ n, m $,$ n $ 表示初始序列有 $ n $ 个数,这个序列依次是 $ \{ 1, 2, \ldots n - 1, n \} $,$ m $ 表示翻转操作次数。

接下来 $ m $ 行每行两个数 $ [l, r] $,数据保证 $ 1 \leq l \leq r \leq n $。

Output

输出一行 $ n $ 个数字,表示原始序列经过 $ m $ 次变换后的结果。

Example

Input

5 3
1 3
1 3
1 4

Output

4 3 2 1 5

Notes

$ 1 \leq n, m \leq 10 ^ 5 $

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.