22838_Cowese

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

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

Pro.ID

22838

Title

Cowese

Title链接

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

AC

0

Submit

3

Ratio

0.00%

时间&空间限制

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

    It is a little known fact that the cows love word games. They have their own cow crossword puzzles, cow word-find grids, and all sorts of other cow word games.

    The cows need some computer assistance, though, in order to design certain word games. They have lists of N distinct words (2 ≤ N ≤ 20,000) no longer than 100 characters, all of which are lower-case and contain only the letters 'a'..'z'.

    They need to find two words in the list that share the longest prefix (i.e., the first C characters of the words match and C is the longest length for all possible pairs of words). The input datasets are guaranteed to have at least one pair of words with a shared prefix.

    If more than two word pairs share prefixes of the same maximal size, the cows want to see the pair whose first word is closest to the beginning of the supplied list and whose other maximal-prefix word is closest to the beginning of the list.

    输入

    * Line 1: One line with a single integer: N

    * Lines 2..N+1: Each line contains a single word.

    输出

    Description

    It is a little known fact that the cows love word games. They have their own cow crossword puzzles, cow word-find grids, and all sorts of other cow word games.

    The cows need some computer assistance, though, in order to design certain word games. They have lists of N distinct words (2 ≤ N ≤ 20,000) no longer than 100 characters, all of which are lower-case and contain only the letters 'a'..'z'.

    They need to find two words in the list that share the longest prefix (i.e., the first C characters of the words match and C is the longest length for all possible pairs of words). The input datasets are guaranteed to have at least one pair of words with a shared prefix.

    If more than two word pairs share prefixes of the same maximal size, the cows want to see the pair whose first word is closest to the beginning of the supplied list and whose other maximal-prefix word is closest to the beginning of the list.

    Input

    * Line 1: One line with a single integer: N

    * Lines 2..N+1: Each line contains a single word.

    Output

    Two lines, each with a single word.

    Sample Input

    9
    noon
    is
    lunch
    for
    most
    noone
    waits
    until
    two

    Sample Output

    noon
    noone

    Source

    样例输入

    9
    noon
    is
    lunch
    for
    most
    noone
    waits
    until
    two

    样例输出

    noon
    noone

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部