CF292E.Copying Data

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

We often have to copy large volumes of information. Such operation can take up many computer resources. Therefore, in this problem you are advised to come up with a way to copy some part of a number array into another one, quickly.

More formally, you've got two arrays of integers a1,a2,...,ana_{1},a_{2},...,a_{n} and b1,b2,...,bnb_{1},b_{2},...,b_{n} of length nn . Also, you've got mm queries of two types:

  1. Copy the subsegment of array aa of length kk , starting from position xx , into array bb , starting from position yy , that is, execute by+q=ax+qb_{y+q}=a_{x+q} for all integer qq (0<=q<k) . The given operation is correct — both subsegments do not touch unexistent elements.
  2. Determine the value in position xx of array bb , that is, find value bxb_{x} .

For each query of the second type print the result — the value of the corresponding element of array bb .

输入格式

The first line contains two space-separated integers nn and mm (1<=n,m<=105)(1<=n,m<=10^{5}) — the number of elements in the arrays and the number of queries, correspondingly. The second line contains an array of integers a1,a2,...,ana_{1},a_{2},...,a_{n} (ai<=109)(|a_{i}|<=10^{9}) . The third line contains an array of integers b1,b2,...,bnb_{1},b_{2},...,b_{n} (bi<=109)(|b_{i}|<=10^{9}) .

Next mm lines contain the descriptions of the queries. The ii -th line first contains integer tit_{i} — the type of the ii -th query (1<=ti<=2)(1<=t_{i}<=2) . If ti=1t_{i}=1 , then the ii -th query means the copying operation. If ti=2t_{i}=2 , then the ii -th query means taking the value in array bb . If ti=1t_{i}=1 , then the query type is followed by three integers xi,yi,kix_{i},y_{i},k_{i} (1<=xi,yi,ki<=n)(1<=x_{i},y_{i},k_{i}<=n) — the parameters of the copying query. If ti=2t_{i}=2 , then the query type is followed by integer xix_{i} (1<=xi<=n)(1<=x_{i}<=n) — the position in array bb .

All numbers in the lines are separated with single spaces. It is guaranteed that all the queries are correct, that is, the copying borders fit into the borders of arrays aa and bb .

输出格式

For each second type query print the result on a single line.

输入输出样例

  • 输入#1

    5 10
    1 2 0 -1 3
    3 1 5 -2 0
    2 5
    1 3 3 3
    2 5
    2 4
    2 1
    1 2 1 4
    2 1
    2 4
    1 4 2 1
    2 2
    

    输出#1

    0
    3
    -1
    3
    2
    3
    -1
    
首页