#589. 「Nowcoder多校 2019 Day4」merge

「Nowcoder多校 2019 Day4」merge

当前没有测试数据。

题目描述

链接:https://ac.nowcoder.com/acm/contest/884/F 来源:牛客网

a is a permutation of 1N1…N ,the original values are given.

There are M operations, each of them is of one of two types:

1 l m r , alr al…r​ with merge(alm,am+1r) merge(al…m​,am+1…r​) .

2 i , means that you need to answer the value ai ai ​ .

Where merge(a,b) means the following code:

def merge(a,b):
  c=[]
  while a.size() and b.size():
    if a[0]<b[0]:
      c.append(a[0])
      a.pop_front()
    else:
      c.append(b[0])
      b.pop_front()
  return c+a+b

输入格式

The first line contains two integer N,M .

The second line contains N integers a1N a1…N .

For the following M lines, each line is of format 1 l m r or 2 i .

输出格式

For each operation of the second type, output a line containing the answer.

样例

样例输入 1

5 3
2 3 1 4 5
2 3
1 1 3 5
2 3

样例输出 1

1
1

数据范围与提示

1≤N,M≤105,1=l≤m<r≤N,1≤i≤N