【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 [题解]这 ...
随机推荐
- [BZOJ4817][SDOI2017]树点涂色(LCT+DFS序线段树)
4817: [Sdoi2017]树点涂色 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 692 Solved: 408[Submit][Status ...
- bzoj 1009 DP 矩阵优化
原来的DP: dp[i][j]表示长度为i的合法串,并且它的长度为j的后缀是给定串的长度为j的前缀. 转移: i==0 dp[0][0] = 1 dp[0][1~m-1] = 0 i>=1 dp ...
- bzoj 2733: [HNOI2012]永无乡 -- 线段树
2733: [HNOI2012]永无乡 Time Limit: 10 Sec Memory Limit: 128 MB Description 永无乡包含 n 座岛,编号从 1 到 n,每座岛都有自 ...
- CCTableView使用及其ViewSize动态调整
cocos2dx的CCTableView使用及其ViewSize动态调整,直接上代码参考如下: // // summary : 水平滑动样式的TableView用法 void createGlobal ...
- Effective C++:条款29:为“异常安全”而努力是值得的
(一)先看以下这些代码: class PrettyMenu { public: void changeBackground(istream& imgSrc); private: Mutex m ...
- frp, https, http, nginx 多服务, ssl等配置
server { listen 80 default_server; listen [::]:80 default_server; root /var/www/html; # Add index.ph ...
- 使用NSHashTable存储引用对象
NSHashTable 我们使用集合(NSArray,NSMutableArray,NSDictionary,NSMutableDictionary,NSSet,NSMutableSet)存储对象时会 ...
- 不会提示是否关闭浏览器 IE6、IE7、FF通用代码
start = setInterval('CloseWin();', 2000); function CloseWin() //这个不会提示是否关闭浏览器 IE6.IE7.FF通用代码: { if ( ...
- flush清空输入输出流
#include <string.h> #include <stdio.h> #include <conio.h> #include <io.h> vo ...
- 将matlab的figure保存为pdf,避免图片太大缺失
有时画的matlab图太大,或者有太多的子图,导致图太宽,如果直接保存成pdf的话,会导致左右边丢失,显示不下.一个有效又简单的办法是: 1.在matlab figure里面,Edit -> ...