Problem Statement
You are given strings $S$ and $T$ of length $N$ consisting of X and Y. For each $i = 1, 2, \dots, N$, you can swap the $i$-th character of $S$ and the $i$-th character of $T$ or choose not to do it. There are $2^N$ pairs of strings that can result from this process, including duplicates. Find the longest string that is a common subsequence (not necessarily contiguous) of one of such pairs. If there are multiple such strings, find the lexicographically smallest of them.
What is a common subsequence? A subsequence of string $S$ is a string obtained by deleting zero or more characters from $S$ and concatenating the remaining characters without changing the order. A common subsequence of strings $S$ and $T$ is a string that is a subsequence of both $S$ and $T$. (See also Sample Output 1.)
Constraints
$1 \leq N \leq 50$- Each of
$S$and$T$is a string of length$N$consisting ofXandY.
Input
The input is given from Standard Input in the following format:
N
S
T
Output
Print the lexicographically smallest of the longest strings that can be a common subsequence of the resulting pair of strings.
样例
3
XXX
YYY
XY
1
X
Y
4
XXYX
YYYY
XYY
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。