Codeforces Round #424 (Div. 2) B. Keyboard Layouts(字符串处理)
2017-07-17 18:18
441 查看
B. Keyboard Layouts
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
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.
Input
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.
Output
Print the text if the same keys were pressed in the second layout.
Examples
input
output
input
output
题意:给出两串字符串,一一对应,然后给出一个目标串让你翻译出来。
分析:简单的密码解锁问题,记录一下对应的字符,再记录一下它们的大写,然后对应输出就可以了
AC代码:
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
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.
Input
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.
Output
Print the text if the same keys were pressed in the second layout.
Examples
input
qwertyuiopasdfghjklzxcvbnm veamhjsgqocnrbfxdtwkylupzi TwccpQZAvb2017
output
HelloVKCup2017
input
mnbvcxzlkjhgfdsapoiuytrewq asdfghjklqwertyuiopzxcvbnm 7abaCABAABAcaba7
output
7uduGUDUUDUgudu7
题意:给出两串字符串,一一对应,然后给出一个目标串让你翻译出来。
分析:简单的密码解锁问题,记录一下对应的字符,再记录一下它们的大写,然后对应输出就可以了
AC代码:
#include<stdio.h> #include<string.h> #include<map> using namespace std; map<char,char>q; int main() { char a[30],b[30]; scanf("%s",a); scanf("%s",b); q.clear(); for(int i=0;i<26;i++) { q[a[i]]=b[i]; q[a[i]-32]=b[i]-32; } char aim[2000]; scanf("%s",aim); for(int i=0;aim[i];i++) { if(q[aim[i]]) printf("%c",q[aim[i]]); else printf("%c",aim[i]); } printf("\n"); }
相关文章推荐
- Codeforces Round #324 (Div. 2) C. Marina and Vasya 字符串处理
- Codeforces Round #FF (Div. 2/B)/Codeforces447B_ DZY Loves Strings(字符串处理)
- Codeforces Round #173 (Div. 2) / 282C XOR and OR (字符串处理)
- Codeforces Round #130 (Div. 2)A Dubstep(简单字符串处理)
- Codeforces Round #163 (Div. 2) / 226A Stones on the Table (字符串处理)
- Codeforces Round #373 (Div. 2) C. Efim and Strange Grade 贪心、实数字符串"a.b"处理
- Codeforces Round #329 (Div. 2)A 字符串处理
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals)C. Jury Marks
- Codeforces Round #149 (Div. 2) E. XOR on Segment(21棵线段树处理每一位+区间异或)
- Codeforces Round #293 (Div. 2) -- A. Vitaly and Strings (字符串构造)
- Codeforces Beta Round #65 (Div. 2) / 71A Way Too Long Words(字符串操作)
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals)C. Jury Marks
- Codeforces Round #313 (Div. 2) D.Equivalent Strings (字符串)
- Codeforces Round #424 (Div. 2)A-B-C 日常训练
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals)C. Jury Marks
- 字符串(后缀自动机):Codeforces Round #129 (Div. 1) E.Little Elephant and Strings
- 【Codeforces Round 362 (Div 2)F】【AC自动机+矩阵快速幂】Legen... 长度为l字符串最大能够重复匹配的字符串权值
- Codeforces Round #218 (Div. 2) (线段树区间处理)
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals)C. Jury Marks
- Educational Codeforces Round 17 C. Two strings(字符串前缀后缀处理,好题)