【CODEFORCES】 A. Keyboard
2 seconds
256 megabytes
standard input
standard output
Our good friend Mole is trying to code a big message. He is typing on an unusual keyboard with characters arranged in following way:
qwertyuiop
asdfghjkl;
zxcvbnm,./
Unfortunately Mole is blind, so sometimes it is problem for him to put his hands accurately. He accidentally moved both his hands with one position to the left or to the right. That means that now he presses not a button he wants, but one neighboring button
(left or right, as specified in input).
We have a sequence of characters he has typed and we want to find the original message.
First line of the input contains one letter describing direction of shifting ('L' or 'R' respectively
for left or right).
Second line contains a sequence of characters written by Mole. The size of this sequence will be no more than 100. Sequence contains only symbols
that appear on Mole's keyboard. It doesn't contain spaces as there is no space on Mole's keyboard.
It is guaranteed that even though Mole hands are moved, he is still pressing buttons on keyboard and not hitting outside it.
Print a line that contains the original message.
R
s;;upimrrfod;pbr
allyouneedislove
题解:水题,打两个表即可了。
#include <iostream>
#include <cstdio>
#include <cstring> using namespace std; char c,s[150];
int r[30]={97,'v','x','s','w','d','f','g','u','h','j','k','n','b','i','o',97,'e','a','r','y','c','q','z','t',97},
l[30]={'s','n','v','f','r','g','h','j','o','k','l',';',',','m','p','[','w','t','d','y','i','b','e','c','u','x'}; int main()
{
scanf("%c",&c);
if (c=='R')
{
scanf("%s",s);
for (int i=0;i<strlen(s);i++) if (s[i]=='[') cout <<"p";
else if (s[i]==';') cout <<"l";
else if (s[i]==',') cout <<"m";
else if (s[i]=='.') cout <<",";
else if (s[i]=='/') cout <<".";
else printf("%c",r[s[i]-97]);
}
if (c=='L')
{
scanf("%s",s);
for (int i=0;i<strlen(s);i++) if (s[i]=='.') cout <<"/";
else if (s[i]==',') cout <<".";
else printf("%c",l[s[i]-97]);
}
return 0;
}
【CODEFORCES】 A. Keyboard的更多相关文章
- 【Codeforces】Round #491 (Div. 2) 总结
[Codeforces]Round #491 (Div. 2) 总结 这次尴尬了,D题fst,E没有做出来.... 不过还好,rating只掉了30,总体来说比较不稳,下次加油 A:If at fir ...
- 【Codeforces】Round #488 (Div. 2) 总结
[Codeforces]Round #488 (Div. 2) 总结 比较僵硬的一场,还是手速不够,但是作为正式成为竞赛生的第一场比赛还是比较圆满的,起码没有FST,A掉ABCD,总排82,怒涨rat ...
- 【CodeForces】601 D. Acyclic Organic Compounds
[题目]D. Acyclic Organic Compounds [题意]给定一棵带点权树,每个点有一个字符,定义一个结点的字符串数为往下延伸能得到的不重复字符串数,求min(点权+字符串数),n&l ...
- 【Codeforces】849D. Rooter's Song
[算法]模拟 [题意]http://codeforces.com/contest/849/problem/D 给定n个点从x轴或y轴的位置p时间t出发,相遇后按对方路径走,问每个数字撞到墙的位置.(还 ...
- 【CodeForces】983 E. NN country 树上倍增+二维数点
[题目]E. NN country [题意]给定n个点的树和m条链,q次询问一条链(a,b)最少被多少条给定的链覆盖.\(n,m,q \leq 2*10^5\). [算法]树上倍增+二维数点(树状数组 ...
- 【CodeForces】925 C.Big Secret 异或
[题目]C.Big Secret [题意]给定数组b,求重排列b数组使其前缀异或和数组a单调递增.\(n \leq 10^5,1 \leq b_i \leq 2^{60}\). [算法]异或 为了拆位 ...
- 【CodeForces】700 D. Huffman Coding on Segment 哈夫曼树+莫队+分块
[题目]D. Huffman Coding on Segment [题意]给定n个数字,m次询问区间[l,r]的数字的哈夫曼编码总长.1<=n,m,ai<=10^5. [算法]哈夫曼树+莫 ...
- 【CodeForces】906 D. Power Tower 扩展欧拉定理
[题目]D. Power Tower [题意]给定长度为n的正整数序列和模数m,q次询问区间[l,r]累乘幂%m的答案.n,q<=10^5,m,ai<=10^9. [算法]扩展欧拉定理 [ ...
- 【CodeForces】741 D. Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths(dsu on tree)
[题意]给定n个点的树,每条边有一个小写字母a~v,求每棵子树内的最长回文路径,回文路径定义为路径上所有字母存在一种排列为回文串.n<=5*10^5. [算法]dsu on tree [题解]这 ...
随机推荐
- [NOI2009]诗人小G --- DP + 决策单调性
[NOI2009]诗人小G 题目描述: 小G是一个出色的诗人,经常作诗自娱自乐. 但是,他一直被一件事情所困扰,那就是诗的排版问题. 一首诗包含了若干个句子,对于一些连续的短句,可以将它们用空格隔开并 ...
- Eclipse下mallet使用的方法
Mallet是Umass大牛开发的一个关于统计自然语言处理的l的开源库,很好的一个东西.可以用来学topic model,训练ME模型等.对于开发者来说,其官网的技术文档是非常有效的. mallet下 ...
- 置换python2.7.13的opcode遇到的一些坑
主要有两个坑 1.XXXSLICE相关的opcode #define SLICE #define SLICE_1 #define SLICE_2 #define SLICE_3 #define STO ...
- HDU 5670 Machine 水题
Machine 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5670 Description There is a machine with m(2 ...
- Ubuntu 16.04开启SFTP服务
说明:其实只要安装了SSH服务就已经具备了SFTP功能,这个用普通客户端无法连接,只能用支持SFTP协议的客户端才能连接. FileZilla作为FTP客户端,它也可以连接SFTP,SFTP的监听端口 ...
- word2010图片仅仅显示边框
有两个可能的原因: 1.图片所在段落的行间距被设置成固定值了 解决:选择所在段落,右键选择段落--弹出[段落]设置对话框--把固定行距改为"单倍行距"或其它--确定. 2.显示设置 ...
- unidac记录日志
unidac记录日志 1)SQL日志记录 TUniSqlMonitor的OnSql事件里面记录SQL日志,演示代码如下: procedure TfrmDB.UniSQLMonitor1SQL(Send ...
- 【spring data jpa】jpa中criteria拼接in查询
示例代码: public static Specification<GoodsType> where(final GoodsType goodsType){ return new Spec ...
- Facebook产品的开发流程
[编者注]王淮是Facebook第二位中国籍工程师,也是第一位中国籍研发经理,他一手开创了Facebook的支付安全和客服工具领域.2011年他离开Facebook,回国成为天使投资人,希望用自己在F ...
- 利用FPGA实现PCI总线接口及Windows驱动实现
利用FPGA实现PCI总线接口及Windows驱动实现 关于PCI总线协议,资料网上.书本都是.这里我们仅仅对重点对利用FPGA实现PCI总线接口问题进行简单分析.下图是PCI总线接口信号: 配置空间 ...