CF292E.Copying Data
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
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 _a_1, _a_2, ..., a__n and _b_1, _b_2, ..., b__n of length n. Also, you've got m queries of two types:
- Copy the subsegment of array a of length k, starting from position x, into array b, starting from position y, that is, execute b__y + q = a__x + q for all integer q (0 ≤ q < k). The given operation is correct — both subsegments do not touch unexistent elements.
- Determine the value in position x of array b, that is, find value b__x.
For each query of the second type print the result — the value of the corresponding element of array b.
我们经常需要复制大量信息,而这种操作会占用大量计算机资源。因此,在本题中,你需要设计一种方法,能够快速地将一个整数数组的某一部分复制到另一个数组中。
更准确地说,你有两个长度为 $ n $ 的整数数组:$ a_1,,a_2,,\dots,,a_n $ 和 $ b_1,,b_2,,\dots,,b_n $。此外,你还有 $ m $ 个查询,分为两类:
- 将数组 $ a $ 中从位置 $ x $ 开始、长度为 $ k $ 的子段复制到数组 $ b $ 中从位置 $ y $ 开始的位置,即对所有整数 $ q $(满足 $ 0 \leq q < k $),执行赋值操作 $ b_{y+q} = a_{x+q} $。该操作保证合法——两个子段均不会访问不存在的元素。
- 查询数组 $ b $ 中位置 $ x $ 处的值,即求 $ b_x $ 的值。
对于每个第二类查询,请输出结果——即数组 $ b $ 中对应位置的元素值。
输入格式
The first line contains two space-separated integers n and m (1 ≤ n, m ≤ 105) — the number of elements in the arrays and the number of queries, correspondingly. The second line contains an array of integers _a_1, _a_2, ..., a__n (|a__i| ≤ 109). The third line contains an array of integers _b_1, _b_2, ..., b__n (|b__i| ≤ 109).
Next m lines contain the descriptions of the queries. The i-th line first contains integer t__i — the type of the i-th query (1 ≤ t__i ≤ 2). If t__i = 1, then the i-th query means the copying operation. If t__i = 2, then the i-th query means taking the value in array b. If t__i = 1, then the query type is followed by three integers x__i, y__i, k__i (1 ≤ x__i, y__i, k__i ≤ n) — the parameters of the copying query. If t__i = 2, then the query type is followed by integer x__i (1 ≤ x__i ≤ n) — the position in array b.
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 a and b.
第一行包含两个以空格分隔的整数 n 和 m(1 ≤ n, m ≤ 105),分别表示数组中元素的个数以及查询的个数。
第二行包含一个整数数组 a1, a2, ..., an(∣ai∣ ≤ 109)。
第三行包含一个整数数组 b1, b2, ..., bn(∣bi∣ ≤ 109)。
接下来 m 行描述各次查询。第 i 行首先包含一个整数 ti —— 第 i 次查询的类型(1 ≤ ti ≤ 2)。若 ti = 1,则第 i 次查询表示一次复制操作;若 ti = 2,则第 i 次查询表示从数组 b 中取值。
当 ti = 1 时,该查询类型后紧跟三个整数 xi, yi, ki(1 ≤ xi, yi, ki ≤ n)—— 即复制操作的参数;
当 ti = 2 时,该查询类型后紧跟一个整数 xi(1 ≤ xi ≤ n)—— 即在数组 b 中的位置。
每行中的所有数字均以单个空格分隔。保证所有查询均合法,即复制操作所涉及的边界均落在数组 a 和 b 的有效范围内。
输出格式
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
输入解题思路,AI测评打分。不知道怎么写?