21781_Editdistance

2022-5-16 18:20| 发布者: Hocassian| 查看: 31| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-4-89505841948200-Problem List-采集的数据-后羿采集器.html

Pro.ID

21781

Title

Edit distance

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21781

AC

13

Submit

33

Ratio

39.39%

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/32768 K (Java/Others)
  • 描述

    Given a string, an edit script is a set of instructions to turn it into another string. There are four kinds of instructions in an edit script:

    Add ('a'): Output one character. This instruction does not consume any characters from the source string.

    Delete ('d'): Delete one character. That is, consume one character from the source string and output nothing.

    Modify ('m'): Modify one character. That is, consume one character from the source string and output a character.

    Copy ('c'): Copy one character. That is, consume one character from the source string and output the same character.

    Now, We define that A shortest edit script is an edit script that minimizes the total number of adds and deletes.

    Given two strings, generate a shortest edit script that changes the first into the second.

    输入

    The input consists of two strings on separate lines. The strings contain only alphanumeric characters. Each string has length between 1 and 10000, inclusive.

    输出

    Description

    Given a string, an edit script is a set of instructions to turn it into another string. There are four kinds of instructions in an edit script:

    Add ('a'): Output one character. This instruction does not consume any characters from the source string.

    Delete ('d'): Delete one character. That is, consume one character from the source string and output nothing.

    Modify ('m'): Modify one character. That is, consume one character from the source string and output a character.

    Copy ('c'): Copy one character. That is, consume one character from the source string and output the same character.

    Now, We define that A shortest edit script is an edit script that minimizes the total number of adds and deletes.

    Given two strings, generate a shortest edit script that changes the first into the second.

    Input

    The input consists of two strings on separate lines. The strings contain only alphanumeric characters. Each string has length between 1 and 10000, inclusive.

    Output

    The output is a shortest edit script. Each line is one instruction, given by the one-letter code of the instruction (a, d, m, or c), followed by a space, followed by the character written (or deleted if the instruction is a deletion).

    In case of a tie, you must generate shortest edit script, and must sort in order of a, d, m, c.

    Therefore, there is only one answer.

    Sample Input

    abcde
    xabzdey

    Sample Output

    a x
    a a
    m b
    m z
    m d
    m e
    m y

    Source

    样例输入

    abcde
    xabzdey

    样例输出

    a x
    a a
    m b
    m z
    m d
    m e
    m y

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部