10189_LetterGame

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

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

Pro.ID

10189

Title

Letter Game

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 600/300 MS (Java/Others)     Memory Limit: 131072/131072 K (Java/Others)
  • 描述


    Figure 1: Each of the 26 lowercase letters and its value

    Letter games are popular at home and on television. In one version of the game, every letter has a value, and you collect letters to form one or more words giving the highest possible score. Unless you have 'a way with words', you will try all the words you know, sometimes looking up the spelling, and then compute the scores. Obviously, this can be done more accurately by computer.

    Given the values in Figure 1, a list of words, and the letters collected: find the highest scoring words or pairs of words that can be formed.

    输入

    One line with a string of lowercase letters (from 'a' to 'z'). The string consists of at least 3 and at most 7 letters in arbitrary order.

    DICTIONARY FORMAT ( this is the real dictionary file lgame.dict)

    At most 40,000 lines, each containing a string of at least 3 and at most 7 lowercase letters. At the end of this file is a line with a single period ('.'). The file is sorted alphabetically and contains no duplicates.

    SAMPLE DICTIONARY

    profile
    program
    prom
    rag
    ram
    rom
    .

    输出

    Description

    Figure 1: Each of the 26 lowercase letters and its value

    Letter games are popular at home and on television. In one version of the game, every letter has a value, and you collect letters to form one or more words giving the highest possible score. Unless you have 'a way with words', you will try all the words you know, sometimes looking up the spelling, and then compute the scores. Obviously, this can be done more accurately by computer.

    Given the values in Figure 1, a list of words, and the letters collected: find the highest scoring words or pairs of words that can be formed.

    Input

    One line with a string of lowercase letters (from 'a' to 'z'). The string consists of at least 3 and at most 7 letters in arbitrary order.

    DICTIONARY FORMAT ( this is the real dictionary file lgame.dict)

    At most 40,000 lines, each containing a string of at least 3 and at most 7 lowercase letters. At the end of this file is a line with a single period ('.'). The file is sorted alphabetically and contains no duplicates.

    SAMPLE DICTIONARY

    profile
    program
    prom
    rag
    ram
    rom
    .

    Output

    On the first line, your program should write the highest possible score, and on each of the following lines, all the words and/or word pairs from file lgame.dict with this score. Sort the output alphabetically by first word, and if tied, by second word. A letter must not occur more often in an output line than in the input line. Use the letter values given in Figure 1.

    When a combination of two words can be formed with the given letters, the words should be printed on the same line separated by a space. The two words should be in alphabetical order; for example, do not write 'rag prom', only write 'prom rag'. A pair in an output line may consist of two identical words.

    Sample Input

    prmgroa

    Sample Output

    This output uses the tiny sample dictionary above, not the lgame.dict dictionary.


    24
    program
    prom rag
    Source

    样例输入

    prmgroa

    样例输出

    This output uses the tiny sample dictionary above, not the lgame.dict dictionary.


    24
    program
    prom rag

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部