Pro.ID22838 TitleCowese Title链接http://10.20.2.8/oj/exercise/problem?problem_id=22838 AC0 Submit3 Ratio0.00% 时间&空间限制描述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 Sample Output noon Source 样例输入9 样例输出noon 作者 |