博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #449 (Div. 2) A. Scarborough Fair【多次区间修改字符串】
阅读量:7011 次
发布时间:2019-06-28

本文共 1995 字,大约阅读时间需要 6 分钟。

A. Scarborough Fair
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
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, c1, c2, which means that all symbols c1 in range [l, r] (froml-th to r-th, including l and r) are changed into c2. String is 1-indexed.

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

Input

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, c1, c2 (1 ≤ l ≤ r ≤ nc1, c2 are lowercase English letters), separated by space.

Output

Output string s after performing m operations described above.

Examples
input
3 1 ioi 1 1 i n
output
noi
input
5 3 wxhak 3 3 h x 1 5 x a 1 3 w g
output
gaaak
Note

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.

【题意】:看例子。

 【分析】:字符串下标从1开始。。scanf("%s", s+1);

#include 
using namespace std;typedef long long ll;int n,m;char a[150];int L,R;char c1,c2;int main(){ cin>>n>>m; cin>>a; for(int i=1;i<=m;i++) { cin>>L>>R>>c1>>c2; for(int i=L-1;i<=R-1;i++) { if(a[i]==c1) { a[i]=c2; } } } cout<
<
注意字符串的 下标 从1开始!

 

转载于:https://www.cnblogs.com/Roni-i/p/7956260.html

你可能感兴趣的文章
VC++使用IMAPI调用Outlook邮箱客户端和Foxmail邮箱客户端遇到的问题
查看>>
Python字符编码以及循环机制介绍
查看>>
【原创】JDK动态代理,此次之后,永生难忘。
查看>>
collection的框架结构
查看>>
c++中的对象复制
查看>>
ubuntu下linux内核源码阅读工具和调试方法总结
查看>>
PHP生成UTF-8编码的CSV文件用Excel打开乱码的解决办法
查看>>
oracle数据库性能
查看>>
关于VS中的调试信息输出
查看>>
IOS-5个可以帮你优化App的优秀网站
查看>>
ArrayIndexOutOfBoundsException
查看>>
JAVA判断各种类型数据是否为空
查看>>
如何使用kali的Searchsploit查找软件漏洞
查看>>
Vim for Rails developers: Lazy modern configuration
查看>>
十三、Android studio环境的搭建
查看>>
ES6 系列之模板字符串
查看>>
JVM(四)垃圾回收的实现算法和执行细节
查看>>
对象解构与点操作访问究竟谁快
查看>>
Python3入门机器学习(七)- PCA
查看>>
2017阿里,百度,京东java面试+笔试大合集,这些面试题你都会吗?
查看>>