CF831B Keyboard Layouts 题解
Content
给你 \(26\) 个字母的映射(都是小写,大写的映射方式相同),再给你一个字符串 \(s\),求它的映射结果(如果有非字母的字符保持不变)。
数据范围:\(1\leqslant |s|\leqslant 1000\)。
Solution
强大的 \(\texttt{map}\) 正好能够为我们做出映射的功能,我们直接存储每个字母的映射再直接将原字符串映射即可。
Code
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <cstring>
#include <map>
using namespace std;
string a, b, c;
map<char, char> mm;
int main() {
cin >> a >> b;
int len = a.size();
for(int i = 0; i < len; ++i) mm[a[i]] = b[i], mm[a[i] - 32] = b[i] - 32;
cin >> c;
len = c.size();
for(int i = 0; i < len; ++i)
if((c[i] >= 'a' && c[i] <= 'z') || (c[i] >= 'A' && c[i] <= 'Z'))
c[i] = mm[c[i]];
cout << c;
return 0;
}
CF831B Keyboard Layouts 题解的更多相关文章
- Codeforces831B Keyboard Layouts
B. Keyboard Layouts time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces Round #424 B. Keyboard Layouts(字符串,匹配,map)
#include <stdio.h> #include <string.h> ][]; ]; ]; int main(){ scanf(]); scanf(]); scanf( ...
- Codefroces 831B Keyboard Layouts
B. Keyboard Layouts time limit per test 1 second memory limit per test 256 megabytes input standard ...
- CF1238E.Keyboard Purchase 题解 状压/子集划分DP
作者:zifeiy 标签:状压DP,子集划分DP 题目链接:https://codeforces.com/contest/1238/problem/E 题目大意: 给你一个长度为 \(n(n \le ...
- codeforces 831B. Keyboard Layouts 解题报告
题目链接:http://codeforces.com/contest/831/problem/B 题目意思:给出两个长度为26,由小写字母组成的字符串s1和s2,对于给出的第三个字符串s3,写出对应s ...
- 【Codeforces Round #424 (Div. 2) B】Keyboard Layouts
[Link]:http://codeforces.com/contest/831/problem/B [Description] 两个键盘的字母的位置不一样; 数字键的位置一样; 告诉你第一个键盘按某 ...
- Fedora 22中的Locale and Keyboard Configuration
Introduction The system locale specifies the language settings of system services and user interface ...
- OS X: Keyboard shortcuts
Using keyboard shortcuts To use a keyboard shortcut, press a modifier key at the same time as a char ...
- CF-831B
B. Keyboard Layouts time limit per test 1 second memory limit per test 256 megabytes input standard ...
随机推荐
- kibana解决Kibana server is not ready yet问题
找到kbn的config中的xml配置 将es的ip改成真正的ip
- [源码解析] PyTorch 分布式 Autograd (3) ---- 上下文相关
[源码解析] PyTorch 分布式 Autograd (3) ---- 上下文相关 0x00 摘要 我们已经知道 dist.autograd 如何发送和接受消息,本文再来看看如何其他支撑部分,就是如 ...
- 根据VCF构建进化树
VCF2Dis,是一款计算根据vcf文件计算距离矩阵的小工具 1 安装 下载后 tar -zxvf VCF2DisXXX.tar.gz cd VCF2DisXXX make # 添加环境变量即可 2 ...
- 【宏基因组】MEGAN4,MEGAN5和MEGAN6的Linux安装和使用
MEGAN(Metagenome Analyzer)是宏基因组学进行物种和功能研究的常用软件,实际上现在的Diamond+MEGAN6已经是一套比较完整的物种和功能注释流程了. 但是由于各种原因,我们 ...
- ggplot 局部放大
需要安装包:ggforce,下面以R自带数据做局部放大演示. require(ggplot2) require(ggforce) require(reshape2) data(CO2) co2< ...
- 8核cpu,,负载
今天有一个电话面试,面试官问我:CentOS怎么查看CPU负载?我说:看top的第一行有load average.面试官又问:为什么从这就判定是负载高呢?依据是什么呢?然后... 然后我就尴尬了,挂了 ...
- 取gridview中textbox的值【C#】
<asp:GridView ID="gridView" runat="server" OnRowCommand="gridView_RowCom ...
- Shell 管道指令pipe
目录 管道命令pipe 选取命令 cut.grep cut 取出需要的信息 grep 取出需要行.过滤不需要的行 排序命令 sort.wc.uniq sort 排序 假设三位数,按十位数从小到大,个位 ...
- day15 数组
day15 数组 数组 1.什么是数组? 什么是数组? 具备某种相同属性的数据集合 [root@localhost ~]# array_name=(ddd) [root@localhost ~]# d ...
- Linux 设置时区
一.查看和修改Linux的时区 1. 查看当前时区命令 : "date -R" 2. 修改设置Linux服务器时区方法 A命令 : "tzselect" 方法 ...