# | Problem | Pass Rate (passed user / total user) |
---|---|---|
12009 | Caesar salad |
|
13279 | Rearrange |
|
13293 | hijklmnop |
|
Description
Caesar wants to eat salad, but nobody sells salad within his country. Thus, he decides to write a letter to the businessmen outside his country. But to secure his message, he has to encrypt the content of his letter.
The encrypt rule is as follow: For each English character inside his letter, shift it with a fixed number n in positive/negative direction.
For example,
- n = 2, then "IJK" will become "KLM"
- n = 3, then "IJK" will become "LMN"
- n = -2, then "AJK" will become "YHI"
- We do the shifting in a cyclic manner, that is, perform left shift 1 on "A" will become "Z"; right shift 2 on "Y" will become "A"
Actually, this encryption is the well-known Caesar chiper.
Input
Input consists of three UPPERCASE English characters and an integer n, seperated by a whitespace character.
The three uppercase English characters is the Caesar's message, n is the shift amount mentioned above (positive for right shift, negative for left shift).
It is guaranteed that -2147483648 <= n <= 2147483647.
Output
Print Caesar's message after encryption (three UPPERCASE English character).
Sample Input Download
Sample Output Download
Tags
Discuss
Description
There are N students in line according to the seat number, then M pairs of students exchanged their positions in the sequence.
Can you help the teacher find everyone's position according to the seat number 1 ~ N?
For example, N = 4 M = 3, and three exchanges are:
1 2
2 3
3 4
The seat arrangement of students during the exchange process:
1 2 3 4
-> 2 1 3 4
-> 2 3 1 4
-> 2 3 4 1
The final positions of students 1 ~ N are 4 1 2 3
Input
The first line contains two integers N M, the number of students and the number of pairs who exchange positions.
Each of the next M lines contains two integers a b, indicating the seat exchange.
for all test case:
1 <= a, b <= N, M <= 1000
Output
The positions of students after exchanges. Note that you need to print ‘\n’ at the end of the output.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
You are given the mapping between 1~9 and a set of 9 lowercase english letters.
Then, given a word consisting of 4 characters from 1~9 and the given set of 9 lowercase english letters, try to tranform the word by the given mapping.
For example, in the sample input, you are given the string "hijklmnop".
This means the mapping:
1 <-> h, 2 <-> i, 3 <-> j, 4 <-> k, 5 <-> l, 6 <-> m, 7 <-> n, 8 <-> o, 9 <-> p.
Thus, the word "9881" should be transformed to "pooh", while the word "3p6n" should be transformed to "j9m7".
Note:
Testcases 1~2: only number to english letter.
Testcase 3: only english letter to number.
Testcases 4~5: no limit.
Input
Input contains two lines:
9 characters — the mapping between 1~9 and a set of 9 lowercase english letters. It's guaranteed that no same letters.
A 4-character word. It's guaranteed that the word contains only those characters from 1 to 9 and the lowercase english letters that appear in the first line of the input.
Output
Output contains only a line, that is, the word after being tranformed.