아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Hint

시간 제한2초메모리 제한1024 MB

요약
두 정수 수열이 주어질 때, 다른 함수가 길이 제한 안에서 최장 공통 부분 수열을 복원할 수 있는 짧은 힌트를 출력하는 문제입니다.
난이도

보통10점 중 7점

유형
동적 계획법, 분할 정복
정답자
아직 제출이 없습니다

문제

Doc Brown managed to turn his DeLorean into a time machine. He has now set his sights on an even bigger problem: longest common subsequence. When given two sequences of numbers AA and BB with lengths NN and MM, he wants to find the longest (or one of the longest) sequence CC, such that all elements of CC appear in both AA and BB in the same order (but not necessarily consecutively) as in CC. He has managed to write a somewhat slow program which will run for many days until it finds a solution. However, he needs an answer as soon as possible. His initial plan was to leave his program running and then in a few days send its output back in time to his present self. The problem is that time travel requires tremendous amounts of energy, so sending the full solution back in time would be extremely expensive.

Now Doc has a new plan, but he needs your help to implement it. He wants to send a short hint about the solution from the future to the present and then use this hint to reconstruct an optimal solution using the hint. Note that it does not necessarily need to be the same optimal solution as the one from the future.

You should write a program hint.cpp which implements two functions: genHint and solve, which achieve Doc’s plan.

제한

  • 1≤N,M≤2×1051 ≤ N, M ≤ 2 \times 10^5
  • 0≤A_i,B_j<min⁡(N,M)0 ≤ A\_i, B\_j < \min{(N, M)}

예제

이 문제는 공개된 예제가 없습니다.