21365_AnagramGroups

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

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

Pro.ID

21365

Title

Anagram Groups

Title链接

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

AC

38

Submit

90

Ratio

42.22%

时间&空间限制

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

    World-renowned Prof. A. N. Agram's current research deals with large anagram groups. He has just found a new application for his theory on the distribution of characters in English language texts. Given such a text, you are to find the largest anagram groups.

    A text is a sequence of words. A word w is an anagram of a word v if and only if there is some permutation p of character positions that takes w to v. Then, w and v are in the same anagram group. The size of an anagram group is the number of words in that group. Find the 5 largest anagram groups.

    输入

    The input contains words composed of lowercase alphabetic characters, separated by whitespace. It is terminated by EOF. You can assume there will be no more than 30000 words.

    输出

    Description

    World-renowned Prof. A. N. Agram's current research deals with large anagram groups. He has just found a new application for his theory on the distribution of characters in English language texts. Given such a text, you are to find the largest anagram groups.

    A text is a sequence of words. A word w is an anagram of a word v if and only if there is some permutation p of character positions that takes w to v. Then, w and v are in the same anagram group. The size of an anagram group is the number of words in that group. Find the 5 largest anagram groups.

    Input

    The input contains words composed of lowercase alphabetic characters, separated by whitespace. It is terminated by EOF. You can assume there will be no more than 30000 words.

    Output

    Output the 5 largest anagram groups. If there are less than 5 groups, output them all. Sort the groups by decreasing size. Break ties lexicographically by the lexicographical smallest element. For each group output, print its size and its member words. Sort the member words lexicographically and print equal words only once.

    Sample Input

    undisplayed
    trace
    tea
    singleton
    eta
    eat
    displayed
    crate
    cater
    carte
    caret
    beta
    beat
    bate
    ate
    abet

    Sample Output

    Group of size 5: caret carte cater crate trace .
    Group of size 4: abet bate beat beta .
    Group of size 4: ate eat eta tea .
    Group of size 1: displayed .
    Group of size 1: singleton .

    Source

    样例输入

    undisplayed
    trace
    tea
    singleton
    eta
    eat
    displayed
    crate
    cater
    carte
    caret
    beta
    beat
    bate
    ate
    abet

    样例输出

    Group of size 5: caret carte cater crate trace .
    Group of size 4: abet bate beat beta .
    Group of size 4: ate eat eta tea .
    Group of size 1: displayed .
    Group of size 1: singleton .

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部