22106_KINAIsNotAbbreviation

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

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

Pro.ID

22106

Title

KINA Is Not Abbreviation

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

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

    When introducing new terms consisting of several words, it is useful to use abbreviations. An abbreviation is a word that consists of the rst letters of several consecutive words.

    An abbreviation is called unambiguous if the following two conditions are satis ed:

    • It corresponds to exactly one sequence of words in a given text (although this sequence can appear in the text more than once);

    • It does not appear in the text by itself.

    For example, in the text "A recursive acronym KINA means "KINA is not abbreviation"", strings "ARA" and "K" are unambiguous abbreviations, strings "A" and "KINA" are ambiguous abbreviations, and strings "RAA" and "KNA" are not abbreviations.

    To introduce an abbreviation in a text, it is placed in parentheses right after the sequence of words it corresponds to. Future occurrences of this sequence of words can be replaced by the abbreviation. In the example text above, introduction of the abbreviation "K" produces the following text: "A recursive acronym KINA (K) means "K is not abbreviation"".

    If two occurrences of a sequence of words overlap, only one of them can be replaced by the abbreviation. Words in a sequence are separated by one or more non-alphabetic characters. Comparison of words is case-insensitive. For example, "i18n" is an occurrence of the word sequence "I n".

    The effectiveness of an abbreviation is the decrease in the number of letters after introduction of this abbreviation. Only letters are taken into account; spaces, parentheses and all other non-alphabetical characters do not count.

    Given a text, find an unambiguous abbreviation with the maximum effectiveness.

    输入

    The input file contains a text with at most 4000 characters. The text contains only characters with ASCII codes 32 (space) to 126 ("~"), 13 (carriage return), and 10 (line feed).

    输出

    Description

    When introducing new terms consisting of several words, it is useful to use abbreviations. An abbreviation is a word that consists of the rst letters of several consecutive words.

    An abbreviation is called unambiguous if the following two conditions are satis ed:

    • It corresponds to exactly one sequence of words in a given text (although this sequence can appear in the text more than once);

    • It does not appear in the text by itself.

    For example, in the text "A recursive acronym KINA means "KINA is not abbreviation"", strings "ARA" and "K" are unambiguous abbreviations, strings "A" and "KINA" are ambiguous abbreviations, and strings "RAA" and "KNA" are not abbreviations.

    To introduce an abbreviation in a text, it is placed in parentheses right after the sequence of words it corresponds to. Future occurrences of this sequence of words can be replaced by the abbreviation. In the example text above, introduction of the abbreviation "K" produces the following text: "A recursive acronym KINA (K) means "K is not abbreviation"".

    If two occurrences of a sequence of words overlap, only one of them can be replaced by the abbreviation. Words in a sequence are separated by one or more non-alphabetic characters. Comparison of words is case-insensitive. For example, "i18n" is an occurrence of the word sequence "I n".

    The effectiveness of an abbreviation is the decrease in the number of letters after introduction of this abbreviation. Only letters are taken into account; spaces, parentheses and all other non-alphabetical characters do not count.

    Given a text, find an unambiguous abbreviation with the maximum effectiveness.

    Input

    The input file contains a text with at most 4000 characters. The text contains only characters with ASCII codes 32 (space) to 126 ("~"), 13 (carriage return), and 10 (line feed).

    Output

    If there is no unambiguous abbreviation with positive effectiveness, then the output le should contain the single number 0.

    Otherwise, the first line of the output fi le should contain the effectiveness of the optimal abbreviation. The second line should contain the unambiguous abbreviation itself. If there are multiple unambiguous abbreviations with the maximum effectiveness, output any one of them.

    Sample Input

    Sample #1
    This problem name is "KINA is not abbreviation".
    Once again: KINA is not abbreviation.

    Sample #2
    To be or not to be: that is the question.

    Sample #3
    Here is the chorus of the song "Jingle Bells":
    Jingle bells, jingle bells,
    Jingle all the way;
    Oh what fun it is to ride
    In a one-horse open sleigh.

    Sample Output

    Sample #1
    11
    NA


    Sample #2
    0


    Sample #3
    16
    JB

    Hint

    In the fi rst example, the optimal abbreviations are "NA" and "INA".

    In the third example, the optimal abbreviations are "JB" and "BJ".

    Source

    样例输入

    Sample #1
    This problem name is "KINA is not abbreviation".
    Once again: KINA is not abbreviation.

    Sample #2
    To be or not to be: that is the question.

    Sample #3
    Here is the chorus of the song "Jingle Bells":
    Jingle bells, jingle bells,
    Jingle all the way;
    Oh what fun it is to ride
    In a one-horse open sleigh.

    样例输出

    Sample #1
    11
    NA


    Sample #2
    0


    Sample #3
    16
    JB

    提示

    In the fi rst example, the optimal abbreviations are "NA" and "INA".

    In the third example, the optimal abbreviations are "JB" and "BJ".


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部