Logo
(追記) (追記ここまで)

15163번 - Intuidiff 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
7 초 512 MB1511880.000%

문제

Nowadays, web applications let us compare revision history for posts and articles using some variant of the quintessential diff utility that finds a small set of insertions and deletions to transform one document into another.

Here is a typical problem with it. Suppose the original document is made up of two paragraphs, P1 P2, and we edit it to become P2 P1. Then diff might describe the changes as: delete P1, leave P2, insert some new text. The fact that the new text is equal to P1 is not used. So, in some sense, diff is “linear” and does not work in the most convenient way possible when we re-order parts of the document.

Can we do better? (More importantly, can it be finished today?) We will adopt this basic requirement: when a part of the new version of a document has appeared somewhere in the old version, it should be highlighted to reflect this fact.

To capture this idea, define the Intuidiff distance from one document to another as the smallest integer N, such that the second document is the concatenation of N blocks, where each block is either a substring of the original document or a single new character. (Note that we do not need to worry about deletions because, unlike diff, we do not implicitly begin with the original document—instead, it starts off empty. Thus, the Intuidiff distance from a document to itself is 1. But this is the only counter-intuitive thing about it.)

Given two strings, compute and print the Intuidiff distance from the first to the second.

입력

The input consists of two lines. Each line contains a string whose length is between 1 and 500 000 inclusive. Each string only contains alphanumeric and underscore characters.

출력

Display the Intuidiff distance from the first string in the input to the second string in the input.

제한

예제 입력 1

Paragraph_paragraph
paragraph_edit3_Paragraph

예제 출력 1

9

힌트

An optimal Intuidiff concatenation for Sample Input 1 is:

p + aragraph_ + e + d + i + t + 3 + _ + Paragraph

출처

ICPC > Regionals > South Pacific > South Pacific Region > ACM ICPC South Pacific Divisionals > 2016 South Pacific Divisional Contest I번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /