All submissions for this problem are available.
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.
The first line contains the integer Q.
Each line in the next Q lines contains one query.
For each query of the second type, print out the answer sub-string in one line.
- For the first type of query: 0 ≤ i ≤ |S|
- For the second type of query: 1 ≤ i ≤ |S| - len + 1
- Q ≤ 1000, |S| ≤ 1000, sum of value of all lens ≤ 1000:
- Q ≤ 10000, |S| ≤ 10000, sum of value of all lens ≤ 10000:
- Q ≤ 3×105, |S| ≤ 3×105, sum of value of all lens ≤ 3×105:
Input: 5 + 0 ab + 1 c ? 1 3 + 2 dd ? 1 5 Output: acb acddb
- "+ 0 ab": S = "ab"
- "+ 1 c": S = "acb"
- "+ 2 dd": S = "acddb"
|Tags||bit, ltime14, medium-hard, segment-tree, strings, tuananh93|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions