字符串 || CodeForces 591B Rebranding
#include <iostream>
#include <cstdio>
using namespace std;
#define SZ 200005
char c[SZ];
int main()
{
int n, m;
int arr[];
scanf("%d %d", &n, &m);
char a, b;
scanf(" %s", c);
int len = strlen(c);
for(int i = ; i < ; i++)
arr[i] = i;
for(int i = ; i < m; i++)
{
scanf(" %c %c", &a, &b);
int aa = a - 'a', bb = b - 'a', p, q;
for(int j = ; j < ; j++) if(arr[j] == aa) {p = j; break;}
for(int j = ; j < ; j++) if(arr[j] == bb) {q = j; break;}
arr[p] = bb;
arr[q] = aa;
}
for(int j = ; j < len; j++)
{
c[j] = arr[c[j] - 'a'] + 'a';
}
printf("%s\n", c);
return ;
}
字符串 || CodeForces 591B Rebranding的更多相关文章
- codeforces 591B Rebranding (模拟)
Rebranding Problem Description The name of one small but proud corporation consists of n lowercase E ...
- CodeForces 591B Rebranding
水题 #include<cstdio> #include<cstring> #include<cmath> #include<vector> #incl ...
- CodeForces 591B
题目链接: http://codeforces.com/problemset/problem/591/B 题意: 给你一串字符串,字符串里的字符全是a-z的小写字母,下面的m行,是字符串的交换方式, ...
- Codeforces Round #327 (Div2) A~E
CodeForces 591A 题意:在距离为L的两端A,B,相向发射魔法,a(以P1的速度)-->B,A<--b(以P2的速度).假设a-->B,途中相遇,则返回到原点A<- ...
- 多项式模板&题目整理
注:多项式的题目,数组应开:N的最近2的整数次幂的4倍. 多项式乘法 FFT模板 时间复杂度\(O(n\log n)\). 模板: void FFT(Z *a,int x,int K){ static ...
- codeforces 723B Text Document Analysis(字符串模拟,)
题目链接:http://codeforces.com/problemset/problem/723/B 题目大意: 输入n,给出n个字符的字符串,字符串由 英文字母(大小写都包括). 下划线'_' . ...
- Codeforces 176B (线性DP+字符串)
题目链接: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=28214 题目大意:源串有如下变形:每次将串切为两半,位置颠倒形成 ...
- Codeforces Round #309 (Div. 2) B. Ohana Cleans Up 字符串水题
B. Ohana Cleans Up Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/554/pr ...
- Codeforces Round #309 (Div. 2) A. Kyoya and Photobooks 字符串水题
A. Kyoya and Photobooks Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...
随机推荐
- HTTP错误code大全
100 - Continue 101 - Switching Protocols Top Success Codes 200 - OK 201 - Created 202 - Accepted 203 ...
- 018--python 函数参数、变量、前向引用、递归
目录 一.python函数的定义 二.函数参数 三.全局变量和局部变量 四.前向引用 五.递归 一.python函数的定义 python函数是对程序逻辑进行结构化或过程化的一种方法 1 python中 ...
- 斯坦福CS231n—深度学习与计算机视觉----学习笔记 课时26&&27
课时26 图像分割与注意力模型(上) 语义分割:我们有输入图像和固定的几个图像分类,任务是我们想要输入一个图像,然后我们要标记每个像素所属的标签为固定数据类中的一个 使用卷积神经,网络为每个小区块进行 ...
- input required字段;django input输入框不填写会自动变红如何修改
前端页面中,input不输入任何内容时,点击submit时,未填写的input会标红框,有些人还会有"该字段必填的字样"!! 什么鬼,你妹的,js也见不到,css3动画也见不到,怎 ...
- AndroidStudio中添加依赖的三种方式以及如何引入so文件和arr文件
AndroidStudio中添加依赖的三个选项,如图: 分别为:库依赖(Library dependency).文件依赖(File dependency)和module依赖(Module dep ...
- android 四大组件详解
这个文章主要是讲Android开发的四大组件,本文主要分为 一.Activity详解二.Service详解三.Broadcast Receiver详解四.Content Provider详解外加一个重 ...
- thrift配置——windows客户端与linux服务端通信(C++)
windows客户端: 1.首先要安装boost库 下载源文件 2.安装boost之前先要安装python-3.4.0.amd64,很多地方没有说,弄了很久 3.运行bootstrap.bat 生成b ...
- MongoDb 本机删除密码的方法
Terminal Inflection LINUX ESOTERICA, FIXES AND RANTS About Errors Resolved Linux Recommended Books W ...
- python int对象的方法
1.求绝对值 >>> a = -10 >>> a.__abs__() 10 >>> abs(10) 10 2.加法 >>> a ...
- win10家庭版安装
https://www.microsoft.com/zh-cn/software-download/windows10ISO https://www.2cto.com/os/201704/621770 ...