ZOJ3878: Convert QWERTY to Dvorak (Zhejiang 2015), zoj3878dvorak
The 12th Zhejiang Provincial Collegiate Programming Contest
Edward, a poor copy typist, is a user of the Dvorak Layout. But now he has only a QWERTY Keyboard with a brokenCaps LockKey, so Edward never presses the brokenCaps LockKey. luckily, all the other keys on the QWERTY keyboard work well. every day, he has a lot of documents to type. thus he needs a converter to translate QWERTY into Dvorak. can you help him?
The QWERTY Layout and the Dvorak Layout are in the following:
Input
A qwerty document Edward typed. The document has no more than 100 kibibytes. And there are no invalid characters in the document.
Output
The Dvorak document.
Sample Input
Jgw Gqm Andpw a H.soav Patsfk f;doeNfk Gq.d slpt a X,dokt vdtnsaoheKjd yspps,glu pgld; aod yso kd;kgluZ1234567890`~!@#$%^&*()}"']_+-=ZQqWEwe{[\|ANIHDYf.,bt/ABCDEFuvwxyz
Sample Output
Hi, I'm Abel, a Dvorak Layout user.But I've only a Qwerty keyboard.The following lines are for testing:1234567890`~!@#$%^&*()+_-={}[]:"'<>,.?/\|ABCDEFuvwxyzAXJE>Ugk,qf;
This question can be understood without looking at it. Just simulate it based on the corresponding location of the keyboard.
Idea: simply create a table.
#include <iostream>#include <stdio.h>#include <string.h>#include <stack>#include <queue>#include <map>#include <set>#include <vector>#include <math.h>#include <algorithm>using namespace std;#define ls 2*i#define rs 2*i+1#define up(i,x,y) for(i=x;i<=y;i++)#define down(i,x,y) for(i=x;i>=y;i--)#define mem(a,x) memset(a,x,sizeof(a))#define w(a) while(a)#define LL long longconst double pi = acos(-1.0);#define Len 20005#define mod 19999997const int INF = 0x3f3f3f3f;char s1[]= {"-=_+qwertyuiop[]QWERTYUIOP{}asdfghjkl;'ASDFGHJKL:\"zxcvbnm,./ZXCVBNM<>?"};char s2[]= {"[]{}',.pyfgcrl/=\"<>PYFGCRL?+aoeuidhtns-AOEUIDHTNS_;qjkxbmwvz:QJKXBMWVZ"};char c;char print(char c){ for(int i=0; s1[i]; i++) if(s1[i]==c) return s2[i]; return c;}int main(){ w(~scanf("%c",&c)) printf("%c",print(c)); return 0;}