A11391 | Scarborough Fair
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
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.
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.
输出格式
Output string $s$ after performing $m$ operations described above.
输入输出样例
输入 #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.
After the first operation, the string is wxxak.
After the second operation, the string is waaak.
After the third operation, the string is gaaak.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted