题目描述
Read problems statements in Mandarin Chinese .
In this problem you will have to implement a simple editor. The editor maintains the content of a string S and have two following functions:
"+ i x": insert a string x into the current string S after the i'th character of the S (we use 1-indexing in this problem). When i equals to 0 it mean we add x at the beginning of S.
"? i len": Print the sub-string of length len starting at position i'th of S.
At the beginning, the editor holds an empty string. There will be Q queries of the two types described above.
------ Input ------
The first line contains the integer Q.
Each line in the next Q lines contains one query.
------ Output ------
For each query of the second type, print out the answer sub-string in one line.
------ Constraints ------
$For the first type of query: 0 ≤ i ≤ |S|$
$For the second type of query: 1 ≤ i ≤ |S| - len + 1 $
20 points
$Q ≤ 1000, |S| ≤ 1000, sum of value of all lens ≤ 1000: $
30 points
$Q ≤ 10000, |S| ≤ 10000, sum of value of all lens ≤ 10000: $
50 points
$Q ≤ 3×10^{5}, |S| ≤ 3×10^{5}, sum of value of all lens ≤ 3×10^{5}: $
------ Example ------
Input:
5
+ 0 ab
+ 1 c
? 1 3
+ 2 dd
? 1 5
Output:
acb
acddb
------ Explanation ------
$"+ 0 ab": S = "ab"$
$"+ 1 c": S = "acb"$
$"+ 2 dd": S = "acddb"$
输入格式
见题面
输出格式
见题面