#C14176. String List Manager

    ID: 43796 Type: Default 1000ms 256MiB

String List Manager

String List Manager

You are required to implement a string list manager that supports multiple operations on a list of strings. The manager enforces a maximum length \(L\) for any string; if a string exceeds \(L\) characters, it must be truncated to \(L\) characters upon insertion.

The supported operations are:

  • add s: Adds the string s to the list. If s exceeds the maximum allowed length, it is truncated to \(L\) characters.
  • get i: Retrieves and prints the string at index i. If the index is invalid, print "Index out of bounds".
  • remove i: Removes the string at index i from the list. If the index is invalid, do nothing.
  • concat i j: Concatenates the strings from index i to index j (inclusive) and prints the result. If any index is invalid or if \(i > j\), print "Index out of bounds".

The input will be read from stdin and output must be printed to stdout.

inputFormat

The first line contains an integer \(L\) denoting the maximum allowed length of a string.

The second line contains an integer \(Q\) representing the number of operations.

The following \(Q\) lines each contain one operation in one of the following formats:

  • add s
  • get i
  • remove i
  • concat i j

Note: The string in the add operation may contain spaces.

outputFormat

For each get and concat operation, print the result on a new line to stdout. If an index is invalid, print "Index out of bounds".

## sample
5
4
add hello
add world
get 0
get 1
hello

world

</p>