Codeforces Round #424 B. Keyboard Layouts(字符串,匹配,map)
#include <stdio.h>
#include <string.h> char ch[][];
char t[]; int num[]; int main(){
scanf("%s",ch[]);
scanf("%s",ch[]);
scanf("%s",t); for(int i=;i<strlen(ch[]);i++){
num[ch[][i]-'a']=i;
} for(int i=;i<strlen(t);i++){
if(<=t[i]-''&&t[i]-''<=){
printf("%c",t[i]);
}else if('a'<=t[i]&&t[i]<='z'){
printf("%c",ch[][num[t[i]-'a']]);
}else if('A'<=t[i]&&t[i]<='Z'){
printf("%c",ch[][num[t[i]-'A']]-);
} }
printf("\n");
return ;
}
#include <stdio.h>
#include <string.h>
char key[];
int main ()
{
char b,f[],l[],sent[];
int i,j,x;
scanf("%s",f);
scanf("%s",l);
scanf("%s",sent);
for(i=;i<;i++)
{
key[f[i]]=l[i];
key[f[i]-]=l[i]-;
}
for(i=;i<strlen(sent);i++)
{
if(key[sent[i]])
printf("%c",key[sent[i]]);
else
{ printf("%c",sent[i]);
}
}
return ; }
#include<stdio.h> int main()
{
char a[],b[],ch;
int i=;
while((a[i]=getchar())!='\n') i++;
i=;
while((b[i]=getchar())!='\n') i++;
while((ch=getchar())!='\n')
{
if(ch<) printf("%c",ch);
else if(ch<)
{
ch+=;
for(i=;i<;i++)
if(a[i]==ch)
{
printf("%c",b[i]-);
break;
}
}
else
for(i=;i<;i++)
if(a[i]==ch)
{
printf("%c",b[i]);
break;
}
}
return ;
}
#include <bits/stdc++.h>
using namespace std; int main()
{
char a[],c;
int i;
string s1,s2,s;
cin>>s1>>s2>>s;
for(i=;i<;++i)
a[s1[i]]=s2[i];
for(i=;i<s.length();++i)
{
if(s[i]>=&&s[i]<=)
{
c=s[i]+;
s[i]=a[c]-;
}
else if(s[i]>=&&s[i]<=)
{
s[i]=a[s[i]];
}
}
cout<<s;
return ;
}
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std; char s1[],s2[],ch[],s[];
int len; int main()
{
scanf("%s%s%s",s1,s2,s);
for(int i=;i<=;i++)
{
ch[s1[i]]=s2[i];
}
len=strlen(s);
for(int i=;i<len;i++)
{
if(s[i]>='A'&&s[i]<='Z')
{
s[i]+=;
s[i]=ch[s[i]]-;
}
else if(s[i]>='a'&&s[i]<='z')
s[i]=ch[s[i]];
else
s[i]=s[i];
}
printf("%s\n",s);
return ;
}
1 second
256 megabytes
standard input
standard output
There are two popular keyboard layouts in Berland, they differ only in letters positions. All the other keys are the same. In Berland they use alphabet with 26 letters which coincides with English alphabet.
You are given two strings consisting of 26 distinct letters each: all keys of the first and the second layouts in the same order.
You are also given some text consisting of small and capital English letters and digits. It is known that it was typed in the first layout, but the writer intended to type it in the second layout. Print the text if the same keys were pressed in the second layout.
Since all keys but letters are the same in both layouts, the capitalization of the letters should remain the same, as well as all other characters.
The first line contains a string of length 26 consisting of distinct lowercase English letters. This is the first layout.
The second line contains a string of length 26 consisting of distinct lowercase English letters. This is the second layout.
The third line contains a non-empty string s consisting of lowercase and uppercase English letters and digits. This is the text typed in the first layout. The length of s does not exceed 1000.
Print the text if the same keys were pressed in the second layout.
qwertyuiopasdfghjklzxcvbnm
veamhjsgqocnrbfxdtwkylupzi
TwccpQZAvb2017
HelloVKCup2017
mnbvcxzlkjhgfdsapoiuytrewq
asdfghjklqwertyuiopzxcvbnm
7abaCABAABAcaba7
7uduGUDUUDUgudu7
Codeforces Round #424 B. Keyboard Layouts(字符串,匹配,map)的更多相关文章
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals)
http://codeforces.com/contest/831 A. Unimodal Array time limit per test 1 second memory limit per te ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem A - B
Array of integers is unimodal, if: it is strictly increasing in the beginning; after that it is cons ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) A 水 B stl C stl D 暴力 E 树状数组
A. Unimodal Array time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- 【Codeforces Round #424 (Div. 2) B】Keyboard Layouts
[Link]:http://codeforces.com/contest/831/problem/B [Description] 两个键盘的字母的位置不一样; 数字键的位置一样; 告诉你第一个键盘按某 ...
- Codeforces Round #410 (Div. 2)(A,字符串,水坑,B,暴力枚举,C,思维题,D,区间贪心)
A. Mike and palindrome time limit per test:2 seconds memory limit per test:256 megabytes input:stand ...
- Codeforces Round #548 (Div. 2) E 二分图匹配(新坑) or 网络流 + 反向处理
https://codeforces.com/contest/1139/problem/E 题意 有n个学生,m个社团,每个学生有一个\(p_i\)值,然后每个学生属于\(c_i\)社团, 有d天,每 ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals)A,B,C
A:链接:http://codeforces.com/contest/831/problem/A 解题思路: 从前往后分别统计递增,相等,递减序列的长度,如果最后长度和原序列长度相等那么就输出yes: ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem D (Codeforces 831D) - 贪心 - 二分答案 - 动态规划
There are n people and k keys on a straight line. Every person wants to get to the office which is l ...
- Codeforces Round #541 (Div. 2) E 字符串 + 思维 + 猜性质
https://codeforces.com/contest/1131/problem/D 题意 给你n个字符串,字符串长度总和加起来不会超过1e5,定义字符串相乘为\(s*s1=s1+s[0]+s1 ...
随机推荐
- BZOJ4488 JSOI2015最大公约数
显然若右端点确定,gcd最多变化log次.容易想到对每一种gcd二分找最远端点,但这样就变成log^3了.注意到右端点右移时,只会造成一些gcd区间的合并,原本gcd相同的区间不可能分裂.由于区间只有 ...
- 【题解】JLOI2015战争调度
搜索+状压+DP. 注意到一个性质:考虑一棵以x为根的子树,在x到原树的根的路径上的点如果都已经确定了方案,那么x的左右儿子的决策就彼此独立,互不影响了.所以我们考虑状压一条路径上每一层节点的状态,求 ...
- 你试过不用if写代码吗?
我在教新手编程时,喜欢给他们一些小小的挑战,比如:不使用if语句(或者三元运算符.switch语句等)解决一些编程问题.这样做有什么意义吗?事实上,它可以迫使你从不同的角度寻找解决方法,也许可以找到更 ...
- 安徽师大附中%你赛day9 T2 富 解题报告
富 题目背景 出于某些原因, 苟先生在追杀富先生. 题目描述 富先生所在的地方是一个\(n\times m\)的网格,苟先生排出了他的狼狗大军,共有\(k\)条狗,第\(i\)条狗所在的位置为\((x ...
- 【BZOJ 2822】[AHOI2012]树屋阶梯 卡特兰数+高精
这道题随便弄几个数就发现是卡特兰数然而为什么是呢? 我们发现我们在增加一列时,如果这一个东西(那一列)他就一格,那么就是上一次的方案数,并没有任何改变,他占满了也是,然后他要是占两格呢,就是把原来的切 ...
- CVPR2014 Objectness 源码转换(完整版) VS2012 X64 –>win32
一.版本转换 1.将源码中vs2012 X64版本转换为vs2012 win32版本. 2.源码下载及其相关资料下载http://mmcheng.net/zh/bing/ 3.需要下载源码(Pape ...
- [poj 3281]最大流+建图很巧妙
题目链接:http://poj.org/problem?id=3281 看了kuangbin大佬的思路,还用着kuangbin板子orz http://www.cnblogs.com/kuangb ...
- 动态规划:状压DP
状压DP可以用在NP问题的小规模求解中(不理解,感觉和可以搜索的题很类似) 如果状态是个网格,数据范围很小,基本锁定状压DP 例题是BZOJ1725 题意是这样的,给定一个黑白图,然后种田,要求田与田 ...
- 【bzoj1010-toy】斜率优化入门模板
dsy1010: [HNOI2008]玩具装箱 [题目描述] 有n个数,分成连续的若干段,每段(假设从第j个到第i个组成一段)的分数为 (X-L)^2,X为j-i+Sigma(Ck) i<=k& ...
- Emmet 也有快速生成文件头的功能
输入下边加粗的缩写,然后Tab,就OK了http://docs.emmet.io/cheat-sheet/ html:4t <!DOCTYPE HTML PUBLIC "-//W3C/ ...