Problem list
Log in
#r02029 · gras(Original)

가장 긴 공통 부분 수열 (LCS) 2

Unrated 1.0 s 256 MB

LCS란, 두 개의 문자열이 주어졌을때 두 문자열의 부분 수열 중 길이가 가장 긴 부분 수열이다. 두 개의 문자열이 주어졌을때 두 문자열의 LCS를 구하라. 부분 수열이란 원래 문자열에서 일부 문자를 순서를 유지한 채 골라 만들 수 있는 문자열이다.

Input

첫째 줄과 둘째 줄에 두 문자열이 각각 주어진다. 문자열은 알파벳 대문자로만 이루어져 있다.

Output

첫번째 줄에 두 문자열의 LCS를 출력한다. 만약 LCS가 여러개 있는 경우 그중 한개만 출력해도 정답으로 인정된다.

주의: LCS의 길이를 출력하지 말고 LCS만 출력해야 한다.

Constraints

두 문자열의 길이는 1 이상 1000 이하다.

Source
gras(Original) by gras
Appears in
Not part of a ladder, contest or set yet.
Accepted 6 Submissions 9 Acceptance 75% Solvers 3

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code