A higher resolution is required to access the IDE
- 62
Learning Opportunities
This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.
Statement
Goal
This program problem is to replace the characters in a multi-line string m of n lines of length n.A string s is an indication of the character to be replaced and the character after the replacement.
For example, If
In answer, you should output the final figure of the string.
The final figure of the string is the figure in which all letters have been replaced.
For example, If
A set of substitutions is valid if the replacing process is well defined and eventually finishes. If the given set is not valid, output
Below are some example problems. (You can skip the example problems. )
Example1:
ox xx pq
3
owe
uax
oqp
In this case, To replace
Thus, the answer is
xwe
uax
xqq
Example2:
ww aa zz oo ii
3
waz
oiw
stw
In this case, there is no particular replace.
Therefore, the answer is
waz
oiw
stw
Example3:
zy yd da ao
5
zzzzz
yyyyy
ddddd
aaaaa
ooooo
In this case,
Thus, the answer is
ooooo
ooooo
ooooo
ooooo
ooooo
Example4:
gu uy yy yu
4
gggg
uuuu
yyyy
uuuu
In this case,
Therefore, the output is
Example5:
ge sc xi xk
5
sfghh
kindd
xzjtk
uilob
otrne
In this case,
Therefore, the output is
Input
Line 1: A string s for the instructions for character replacement.
Line 2: An integer n for the size of the string figure.
Next n Lines: A multi-line string m.
Line 2: An integer n for the size of the string figure.
Next n Lines: A multi-line string m.
Output
If the instructions are correct, output the final figure.
If not, outputERROR .
If not, output
Constraints
A string s is all lowercase alphabetical characters.
8 <= s.length() < 15
3 <= n <= 5
8 <= s.length() < 15
3 <= n <= 5
Example
Input
ox xx pq 3 owe uax oqp
Output
xwe uax xqq
A higher resolution is required to access the IDE