CF897A.Scarborough Fair

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Are you going to Scarborough Fair?

Parsley, sage, rosemary and thyme.

Remember me to one who lives there.

He once was the true love of mine.

Willem is taking the girl to the highest building in island No.28, however, neither of them knows how to get there.

Willem asks his friend, Grick for directions, Grick helped them, and gave them a task.

Although the girl wants to help, Willem insists on doing it by himself.

Grick gave Willem a string of length n.

Willem needs to do m operations, each operation has four parameters l, r, _c_1, _c_2, which means that all symbols _c_1 in range [l, r] (from l-th to r-th, including l and r) are changed into _c_2. String is 1-indexed.

Grick wants to know the final string after all the m operations.

你将去斯卡伯勒集市吗?

欧芹、鼠尾草、迷迭香和百里香。

请向住在那里的一个人代我问好。

他曾经是我真正的爱人。

威尔姆正带那位姑娘前往第28号岛上的最高建筑,然而他们俩都不知道该如何到达那里。

威尔姆向他的朋友格里克求助,格里克帮了他们,并给他们布置了一项任务。

尽管那位姑娘想帮忙,威尔姆却坚持要独自完成。

格里克给了威尔姆一个长度为 nn 的字符串。

威尔姆需要执行 mm 次操作,每次操作包含四个参数 ll、rr、c1c_1、c2c_2,其含义是:将字符串中区间 [l, r][l,\,r](即从第 ll 个字符到第 rr 个字符,包含端点 ll 和 rr)内所有字符 c1c_1 替换为字符 c2c_2。字符串下标从 1 开始。

格里克想知道经过全部 mm 次操作后所得的最终字符串。

输入格式

The first line contains two integers n and m (1 ≤ n, m ≤ 100).

The second line contains a string s of length n, consisting of lowercase English letters.

Each of the next m lines contains four parameters l, r, _c_1, _c_2 (1 ≤ l ≤ r ≤ n, _c_1, _c_2 are lowercase English letters), separated by space.

第一行包含两个整数 nn 和 mm(1 ≤ n, m ≤ 1001 \le n, m \le 100)。

第二行包含一个长度为 nn 的字符串 ss,由小写英文字母组成。

接下来的 mm 行每行包含四个参数 ll、rr、c1c_1、c2c_2(1 ≤ l ≤ r ≤ n1 \le l \le r \le n,c1c_1、c2c_2 为小写英文字母),以空格分隔。

输出格式

Output string s after performing m operations described above.

执行上述 mm 次操作后,输出字符串 ss。

输入输出样例

  • 输入#1

    3 1
    ioi
    1 1 i n

    输出#1

    noi
  • 输入#2

    5 3
    wxhak
    3 3 h x
    1 5 x a
    1 3 w g

    输出#2

    gaaak

说明/提示

For the second example:

After the first operation, the string is wxxak.

After the second operation, the string is waaak.

After the third operation, the string is gaaak.

对于第二个例子:

第一次操作后,字符串变为 wxxak。

第二次操作后,字符串变为 waaak。

第三次操作后,字符串变为 gaaak。

输入解题思路,AI测评打分。不知道怎么写?

首页