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 ...
随机推荐
- 前端---梳理 http 知识体系 2
为什么要有HTTPS HTTP 天生具有明文的特点,整个传输过程完全透明,任何人都能够在链路中截获.修改或者伪造请求 / 响应报文,数据不具有安全性.仅凭HTTP 自身是无法解决的,需要引入新的HTT ...
- Java 操作符小记
"在最底层,Java中的数据是通过使用操作符来操作的" (Thinking in Java) 1 算术操作符 Java 中的基本算术操作符和其他大多数程序设计语言是相同的.其中包括 ...
- SpringMVC学习笔记---依赖配置和简单案例实现
初识SpringMVC 实现步骤: 新建一个web项目 导入相关jar包 编写web.xml,注册DispatcherServlet 编写springmvc配置文件 接下来就是去创建对应的控制类 , ...
- [洛谷P2000 拯救世界]
生成函数版题. 考虑对于这些条件写出\(OGF\) \(1 + x^6 + x^{12} + x^{18}..... = \frac{1}{1 - x^6}\) \(1 + x + x ^ 2 + x ...
- 洛谷 P7879 -「SWTR-07」How to AK NOI?(后缀自动机+线段树维护矩乘)
洛谷题面传送门 orz 一发出题人(话说我 AC 这道题的时候,出题人好像就坐在我的右侧呢/cy/cy) 考虑一个很 naive 的 DP,\(dp_i\) 表示 \([l,i]\) 之间的字符串是否 ...
- 力扣 - 剑指 Offer 47. 礼物的最大价值
题目 剑指 Offer 47. 礼物的最大价值 思路1 因为是要求最大价值,而且只能移动下方或者右方,因此,每个位置的最大值就是本身的值加上上边 / 左边 中的最大值,然后每次遍历都可以复用上一次的值 ...
- 表格table的宽度问题
首先注意table的一个样式 table { table-layout:fixed; } table-layout有以下取值: automatic 默认.列宽度由单元格内容设定 fixed 列宽由表格 ...
- 分布式事务(3)---强一致性分布式事务Atomikos实战
分布式事务(1)-理论基础 分布式事务(2)---强一致性分布式事务解决方案 分布式事务(4)---最终一致性方案之TCC 前面介绍强一致性分布式解决方案,这里用Atomikos框架写一个实战的dem ...
- absorb
absorb 物理的absorb比较直观.被书本/知识absorb也好理解.涉及到money/time时有点抽象,但汉语也有"吸金"的说法,consume, use up.可以吸收 ...
- DP-Burst Balloons
leetcode312: https://leetcode.com/problems/burst-balloons/#/description Given n balloons, indexed fr ...