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 ...
随机推荐
- [转载] Win7下MATLAB 7.0下载地址和详细安装
移步http://blog.csdn.net/feecooling/article/details/7525140 MATLAB中文手册命令汇总http://wenku.baidu.com/view/ ...
- 【C++ 拾遗】extern 关键字
Separate compilation allows programs to be written in logical parts. let us split our programs into ...
- BZOJ1095 [ZJOI2007]Hide 捉迷藏 【动态点分治 + 堆】
题目链接 BZOJ1095 题解 传说中的动态点分治,一直不敢碰 今日一会,感觉其实并不艰涩难懂 考虑没有修改,如果不用树形dp的话,就得点分治 对于每个重心,我们会考虑其分治的子树内所有点到它的距离 ...
- HDU3038:How Many Answers Are Wrong(带权并查集)
How Many Answers Are Wrong Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Ja ...
- 使用HTML实现对汉字拼音的支持
<!DOCTYPE HTML><html> <head> <meta charset="utf-8"> <title>无 ...
- xml数据格式
<?xml version="1.0" encoding="utf-8"?> <country> <name>中国</ ...
- C++中的垃圾回收和内存管理(续)
boost memory的gc_allocator的使用 首先编译生成boost-memory的库,由于生成的是.so的动态库,所以需要在运行程序之前,将库文件的路径添加到LD_LIBRARY_PAT ...
- 【BZOJ2460】【BJOI2011】元素 [线性基]
元素 Time Limit: 20 Sec Memory Limit: 128 MB[Submit][Status][Discuss] Description 相传,在远古时期,位于西方大陆的 Ma ...
- POJ 3617 Best Cow Line (模拟)
题目链接 Description FJ is about to take his N (1 ≤ N ≤ 2,000) cows to the annual"Farmer of the Yea ...
- [bzoj2002][Hnoi2010]Bounce弹飞绵羊——分块
Brief description 某天,Lostmonkey发明了一种超级弹力装置,为了在他的绵羊朋友面前显摆,他邀请小绵羊一起玩个游戏.游戏一开始,Lostmonkey在地上沿着一条直线摆上n个装 ...