String insertion P21174


Statement
 

pdf   zip

Implement an efficient data structure to keep a dynamic array A[0..] of strings, with two operations:

  • Iss ii: Increase the size of AA by one (like A.push_back("");). Move every string at a position jj such that jij \ge i one position to its right. Store the string ss at the ii-th position, which now is empty.

  • Cjj: Print the jj-th character (0 based) of the whole array, considering the concatenation of all its strings from left to right.

Input

Input consists of just one case. Assume that each ss has between 1 and 10 lowercase letters, each ii is between 0 and the current number of strings, and each jj is between 0 and the current number of characters minus one. The total number of operations is at most 31053 \cdot 10^5. An ‘E’ marks the end of the input.

Output

Print a line with the letter at the jj-th position for each ‘C’ operation.

Public test cases
  • Input

    I hello 0
    C 0
    C 4
    I bye 0
    C 0
    C 7
    I hi 1
    C 4
    C 1
    C 9
    E
    

    Output

    hoboiyo
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Official solutions
    C++
    User solutions
    C++