Codeforces897A-Scarborough Fair
来源:互联网 发布:元胞数组赋值 编辑:程序博客网 时间:2024/04/29 08:30
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] (from l-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.
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 ≤ n, c1, c2 are lowercase English letters), separated by space.
Output string s after performing m operations described above.
3 1ioi1 1 i n
noi
5 3wxhak3 3 h x1 5 x a1 3 w g
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.
水题……
Code:
#include<iostream>#include<cmath>#include<algorithm>#include<cstring>#include<cstdio>#include<cstdlib>using namespace std;char s[105];int main(){int n,m;scanf("%d%d",&n,&m);scanf("%s\n",&s);for(int i=1;i<=m;i++){int x,y;char a,b;scanf("%d%d%c%c%c%c",&x,&y,&a,&a,&b,&b);for(int j=x;j<=y;j++)if(s[j-1]==a)s[j-1]=b;}printf("%s\n",s);return 0;}
- Codeforces897A-Scarborough Fair
- Codeforces897A Scarborough Fair
- scarborough fair
- scarborough fair
- Scarborough Fair -- Paul Simon
- scarborough fair (song)
- About “Scarborough Fair”
- Scarborough Fair 天籁
- A. Scarborough Fair
- Scarborough Fair(斯卡布罗集市)
- 永远的《毕业生》之《Scarborough Fair》
- 《斯加波罗之市》 Scarborough Fair
- 永远的《毕业生》之《Scarborough Fair》
- Scarborough Fair(斯卡布罗集市)歌词赏析
- [天籁之音]《斯卡布罗集市(Scarborough Fair)》
- Stylc.Musie.VOL.29 - Scarborough fair
- codeforces 897 A. Scarborough Fair 【暴力】
- 周赛的题目—Scarborough Fair
- 【Scikit-Learn 中文文档】30 模型评估: 量化预测的质量
- 吴恩达深度学习课程deeplearning.ai课程作业:Class 1 Week 3 assignment3
- 图像处理,机器视觉,机器学习等
- SpringCloud教程第五篇:高可用分布式配置中心
- 速感科技陈震| 如何给予机器一双慧眼
- Codeforces897A-Scarborough Fair
- 教训
- J
- Andrew Ng's deeplearning Course4Week1 Convolutional Neural Networks(卷积神经网络)
- ubuntu 添加用户、用户组
- 频繁模式挖掘FP-Growth(Frequent Pattern Growth)
- caffe之python接口实战 :02-fine-tuning 官方教程源码解析
- Jsonp解决ajax跨域问题
- 简述Android 解决65536/64K方法数限制方案