#P8796. String Replacement Operations
String Replacement Operations
String Replacement Operations
Given a string s consisting of only lowercase English letters, perform a series of replacement operations. In each operation, you are given an interval \([l_i, r_i]\) (1-indexed) and two characters \(x_i\) and \(y_i\). For that operation, replace every occurrence of character \(x_i\) within the substring \(s[l_i...r_i]\) with character \(y_i\).
After performing all operations sequentially, output the final string.
Note: The indices \(l_i\) and \(r_i\) are inclusive and 1-indexed. The operations are applied in the given order.
inputFormat
The input consists of multiple lines:
- The first line contains the string s (only lowercase English letters).
- The second line contains an integer m, the number of operations.
- Each of the next m lines contains an operation in the format:
l r x y
, wherel
andr
are integers (1-indexed), andx
andy
are lowercase English letters.
outputFormat
Output the final string after all operations are executed.
sample
abcde
2
1 3 a z
2 5 c m
zbmde