#abc342c. C - Many Replacement
C - Many Replacement
Score: points
问题描述
你将得到一个长度为 的由小写英文字母组成的字符串 。
你需要对字符串 执行 次操作。第 次操作 由一对字符 表示,对应以下操作:
- 将字符串 中所有出现的字符 替换为字符 。
在所有操作完成后,输出字符串 。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given a string of length consisting of lowercase English letters.
You will perform an operation times on the string . The -th operation is represented by a pair of characters , which corresponds to the following operation:
- Replace all occurrences of the character in with the character .
Print the string after all operations are completed.
Constraints
- is a string of length consisting of lowercase English letters.
- and are lowercase English letters .
- and are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the string after all operations are completed.
Sample Input 1
7
atcoder
4
r a
t e
d v
a r
Sample Output 1
recover
changes as follows: atcoder
→ atcodea
→ aecodea
→ aecovea
→ recover
. For example, in the fourth operation, all occurrences of a
in aecovea
(the first and seventh characters) are replaced with r
, resulting in recover
.
After all operations are completed, recover
, so print recover
.
Sample Input 2
3
abc
4
a a
s k
n n
z b
Sample Output 2
abc
There may be operations where or does not contain .
Sample Input 3
34
supercalifragilisticexpialidocious
20
g c
l g
g m
c m
r o
s e
a a
o f
f s
e t
t l
d v
p k
v h
x i
h n
n j
i r
s i
u a
Sample Output 3
laklimamriiamrmrllrmlrkramrjimrial
update @ 2024/3/10 01:36:09