您现在的位置: 爱51代码网 >> 主页设计 >> 文章正文
ZOJ 3700 Ever Dream 文章中单词的处理 .

ZOJ 3700 Ever Dream 文章中单词的处理 .

"Ever Dream" played by Nightwish is my favorite metal music. The lyric (see Sample Input) of this song is much more like a poem. Every people may have their own interpretation for this song depending on their own experience in the past. For me, it is a song about pure and unrequited love filled with innocence, willingness and happiness. I believe most people used to have or still have a long story with someone special or something special. However, perhaps fatefully, life is totally a joke for us. One day, the story ended and became a dream in the long night that would never come true. The song touches my heart because it reminds me the dream I ever had and the one I ever loved.

Today I recommend this song to my friends and hope that you can follow your heart. I also designed a simple algorithm to express the meaning of a song by several key words. There are only 3 steps in this algorithm, which are described below:

Step 1: Extract all different words from the song and counts the occurrences of each word. A word only consists of English letters and it is case-insensitive.

Step 2: Divide the words into different groups according to their frequencies (i.e. the number of times a word occurs). Words with the same frequency belong to the same group.

Step 3: For each group, output the word with the longest length. If there is a tie, sort these words (not including the words with shorter length) in alphabetical order and output the penultimate one. Here "penultimate" means the second to the last. The word with higher frequency should be output first and you don't need to output the word that just occurs once in the song.

Now given the lyric of a song, please output its key words by implementing the algorithm above.

Input
The first line of input is an integer T (T < 50) indicating the number of test cases. For each case, first there is a line containing the number n (n < 50) indicating that there are n lines of words for the song. The following n lines contain the lyric of the song. An empty line is also counted as a single line. Any ASCII code can occur in the lyric. There will be at most 100 characters in a single line.

Output
For each case, output the key words in a single line. Words should be in lower-case and separated by a space. If there is no key word, just output an empty line.

Sample Input
1
29
Ever felt away with me
Just once that all I need
Entwined in finding you one day

Ever felt away without me
My love, it lies so deep
Ever dream of me

Would you do it with me
Heal the scars and change the stars
Would you do it for me
Turn loose the heaven within

I'd take you away
Castaway on a lonely day
Bosom for a teary cheek
My song can but borrow your grace

Come out, come out wherever you are
So lost in your sea
Give in, give in for my t

[1] [2] [3] [4] [5] [6] 下一页

  • 上一篇文章:

  • 下一篇文章: 没有了
  • 最新文章 热点文章 相关文章
    ZOJ 3700 Ever Dream 文章中单词
    TortoiseGit和msysGit安装及使用
    asp中有一段javascipt的网页鼠标
    sharepoint 2010 获取用户信息Us
    设计包含max函数的队列
    随机从数组中取出指定的不重复的
    mysql主从同步延迟方案解决的学习
    青岛科学六年级下册教材分析
    生日旅行总结
    中小板生日快乐随感
    sharepoint 2010 获取用户信息Us
    mysql主从同步延迟方案解决的学习
    生日旅行总结
    中小板生日快乐随感
    送生日快乐桑葚乳酪小蛋糕
    写给女儿的生日快乐
    总分公司财务核算
    恢复使用繁体字可行性研究报告
    保险受益人制度相关问题的探讨
    初中生地理读图能力培养的研究
    TortoiseGit和msysGit安装及
    Eclipse、MyEclipse使用git插
    asp中有一段javascipt的网页
    js倒计时,即使刷新也没事源
    AJAX 访问php数据库返回结果
    js解析java字符串代码
    C#读txt如何只读取部分内容
    C# winform如何取到一个网页
    “Point”是“System.Drawin
    Google paly上如何赚美元
     



    设为首页 | 加入收藏 | 网站地图 | 友情链接 |