Hieroglyphs
시간 제한1초메모리 제한1024 MB
두 수열 A와 B가 주어질 때, 모든 공통 부분 수열을 부분 수열로 포함하는 보편 공통 부분 수열을 구하거나 존재하지 않음을 판정한다.
문제
A team of researchers is studying the similarities between sequences of hieroglyphs. They represent each hieroglyph with a non-negative integer. To perform their study, they use the following concepts about sequences.
For a fixed sequence , a sequence is called a subsequence of if and only if can be obtained by removing some elements (possibly none) from .
The table below shows some examples of subsequences of a sequence .
On the other hand, or are not subsequences of .
Consider two sequences of hieroglyphs, and . A sequence is called a common subsequence of and if and only if is a subsequence of both and . Moreover, we say that a sequence is a universal common subsequence of and if and only if the following two conditions are met:
- is a common subsequence of and .
- Every common subsequence of and is also a subsequence of .
It can be shown that any two sequences and have at most one universal common subsequence.
The researchers have found two sequences of hieroglyphs and . Sequence consists of hieroglyphs and sequence consists of hieroglyphs. Help the researchers compute a universal common subsequence of sequences and , or determine that such a sequence does not exist.
제한
- for each such that
- for each such that
예제
이 문제는 공개된 예제가 없습니다.