B. No Name

Codeforces
IDCF10015B
Time4000ms
Memory256MB
Difficulty
English · Original
Formal · Original
This is the most direct problem ever, you are required to implement some basic string operations like insert and substring. In this problem |*S*| means the length of the string *S*. _Note: We didn't find a good name for this problem._ The input starts with a line containing a string *S* (1  ≤  |*S*|  ≤  200,000), followed by one or more lines each describing one of the following operations to perform on *S* (all indices are zero based, and the quotes are for clarity): Strings *S* and *R* will consist of lower case English letters only ('a' to 'z'), and |*S*| will never get greater than 200,000 as a result of the operations. Also, the total number of characters to be printed will not exceed 200,000. For every "P *X* *Y*" operation in the input, print one line with the corresponding substring. ## Input The input starts with a line containing a string *S* (1  ≤  |*S*|  ≤  200,000), followed by one or more lines each describing one of the following operations to perform on *S* (all indices are zero based, and the quotes are for clarity): "I *R* *X*" means insert the string *R* (1  ≤  |*R*|  ≤  200,000) in *S* at index *X* (0  ≤  *X*  ≤  |*S*|), when *X* equals |*S*| this means append *R* at the end of *S*. For example, the result of inserting "xy" in "abc" at position 1 will be "axybc", and the result of inserting "xy" in "abc" at position 3 will be "abcxy", and the result of inserting "xy" in "abc" at position 0 will be "xyabc". "P *X* *Y*" means print the substring of *S* from *X* to *Y*, inclusive (0  ≤  *X*  ≤  *Y* < |*S*|). For example the substring from 0 to 2 of "abc" is "abc", and the string from 1 to 1 of "abc" is "b". "END" Indicates the end of operations, and will be last line of the input. Strings *S* and *R* will consist of lower case English letters only ('a' to 'z'), and |*S*| will never get greater than 200,000 as a result of the operations. Also, the total number of characters to be printed will not exceed 200,000. ## Output For every "P *X* *Y*" operation in the input, print one line with the corresponding substring. [samples]
**Definitions** Let $ S \in \Sigma^* $ be the initial string, where $ \Sigma = \{a, b, \dots, z\} $ and $ 1 \leq |S| \leq 200{,}000 $. Let $ \mathcal{O} $ be a sequence of operations of the form: - $ \texttt{I } X \ Y \ R $: Insert string $ R $ into $ S $ at index $ X $, replacing the substring starting at $ X $ of length $ Y $. - $ \texttt{P } X \ Y $: Print the substring $ S[X : X+Y] $ (i.e., from index $ X $ inclusive to $ X+Y $ exclusive). **Constraints** 1. $ |S| \leq 200{,}000 $ at all times. 2. All indices $ X, Y $ satisfy $ 0 \leq X \leq |S| $, $ 0 \leq Y \leq |S| - X $. 3. $ R \in \Sigma^* $, and $ |R| \geq 0 $. 4. Total characters printed across all "P" operations $ \leq 200{,}000 $. **Objective** For each operation $ \texttt{P } X \ Y $, output the substring $ S[X : X+Y] $. For each operation $ \texttt{I } X \ Y \ R $, update $ S \leftarrow S[0:X] + R + S[X+Y:] $.
API Response (JSON)
{
  "problem": {
    "name": "B. No Name",
    "description": {
      "content": "This is the most direct problem ever, you are required to implement some basic string operations like insert and substring. In this problem |*S*| means the length of the string *S*. _Note: We didn't",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 4000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10015B"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "This is the most direct problem ever, you are required to implement some basic string operations like insert and substring.\n\nIn this problem |*S*| means the length of the string *S*.\n\n_Note: We didn't...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ S \\in \\Sigma^* $ be the initial string, where $ \\Sigma = \\{a, b, \\dots, z\\} $ and $ 1 \\leq |S| \\leq 200{,}000 $.  \nLet $ \\mathcal{O} $ be a sequence of operations of the form: ...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments