#P8796. [蓝桥杯 2022 国 AC] 替换字符

    ID: 9712 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>平衡树2022蓝桥杯国赛线段树合并

[蓝桥杯 2022 国 AC] 替换字符

Problem Description

Given a string ss that contains only lowercase English letters, each operation chooses an interval [li,ri][l_i, r_i] and replaces all letters xix_i in this interval of ss with the letter yiy_i. After all operations are completed, output the resulting string.

Input Format

The first line contains a string ss.

The second line contains an integer mm.

The next mm lines each contain 44 parameters li,ri,xi,yil_i, r_i, x_i, y_i, separated by a single space. Here li,ril_i, r_i are integers, and xi,yix_i, y_i are lowercase letters.

Output Format

Output one line containing a string representing the answer.

abcaaea
4
1 7 c e
3 3 e b
3 6 b e
1 4 a c
cbecaea

Hint

【Scale and Constraints of testdata】

  • For 40%40\% of the testdata, s,m5000|s|, m \leq 5000.
  • For all testdata, 1s,m1051 \leq |s|, m \leq 10^5, 1liris1 \leq l_i \leq r_i \leq |s|, xiyix_i \neq y_i, where s|s| denotes the length of the string ss.

Lanqiao Cup 2022 National Contest Group A Problem H (Group C Problem J).

Translated by ChatGPT 5