日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ZOJ 3700 Ever Dream(模拟)

發布時間:2025/3/16 编程问答 16 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ZOJ 3700 Ever Dream(模拟) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題目鏈接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3700 Ever Dream


Time Limit:?2 Seconds ?????Memory Limit:?65536 KB


"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 touch For my taste for my lust Your beauty cascaded on me In this white night fantasy "All I ever craved were the two dreams I shared with you. One I now have, will the other one ever dream remain. For yours I truly wish to be."

Sample Output

for ever with dream 題意:給出一首歌,由n行字符串字符串,每行含有一些單詞,求出這些單詞里面的關鍵詞。 關鍵詞由以下規則生成:1.提取出所有不同的單詞和每個單詞出現的次數,單詞只有英文字母組成,并且不區分大小寫。 2.把這些單詞分成若干組,出現相同次數的單詞分成一個組 3.對于沒一個組,輸出長度最長的單詞;如果有多個單詞長度相同,則先按字典序排序,然后輸出倒數第二個。 注意:像 I'd 這樣的簡寫認為是一個單詞,和題意說的有點不一樣,一直WA在這里。 知道了這些,就可以AC了。 #include <iostream> #include <set> #include <map> #include <string> using namespace std;inline bool Is_alpha(char ch) { // 判斷字符是不是字母if((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))return true;return false; }map <string, int> mp; map <string, int>::iterator it; set <string> ans;int main() {int T, n;string s;cin >> T;while(T--) {cin >> n;cin.ignore();mp.clear();int max_cnt = -1;for(int i = 0; i < n; i++) {getline(cin, s);if(s == "") continue;string str = "";for(int j = 0; j < (int)s.size(); j++) {if(!Is_alpha(s[j])) {if(s[j] != '\'') { // 如果不是單引號,I'd 看做一個單詞if(str.length() > 0) {if(mp[str] == 0) mp[str] = 1;else mp[str]++;max_cnt = max(max_cnt, mp[str]);str = "";}}else str += s[j];}else {if(s[j] >= 'A' && s[j] <= 'Z')s[j] = (s[j] + 32);str += s[j];}}if(str.length() > 0) {if(mp[str] == 0) mp[str] = 1;else mp[str]++;max_cnt = max(max_cnt, mp[str]);str = "";}}int flag = 0;for(int i = max_cnt; i >= 2; i--) {ans.clear();int max_len = 0;for(it = mp.begin(); it != mp.end(); it++) {if(it->second == i) { // 找出長度為i的最長字符串if((it->first.length()) > max_len) {max_len = it->first.length();ans.clear();ans.insert(it->first);}else if(it->first.length() == max_len)ans.insert(it->first);}}if(ans.size() == 1) {if(flag) cout << " ";cout << *ans.begin();flag = 1;}else {if(ans.size() >= 2) {set <string> ::iterator sit = ans.end();sit--;sit--;if(flag) cout << " ";cout << *sit;flag = 1;}}}cout << endl;}return 0; }


總結

以上是生活随笔為你收集整理的ZOJ 3700 Ever Dream(模拟)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 亚洲在线观看一区 | 久久精品国产99久久不卡 | 国产亚洲制服欧洲高清一区 | 久久久久久夜 | 激情小说一区 | 17c国产精品| 老色批网站 | 欧美亚洲另类在线 | 学生调教贱奴丨vk | 国产欧美不卡 | 波多野结衣一区二区三区高清 | 欧美日韩久久婷婷 | 欧美三级视频在线播放 | 中文写幕一区二区三区免费观成熟 | 亚洲黄网在线 | 色综合自拍 | 成年人免费av | 亚洲精品黄 | 免费在线播放视频 | 日韩激情国产 | 怡春院国产| 国产一级免费 | 亚洲欧美在线不卡 | 久久传媒 | 欧美色综合色 | 国产精品自拍合集 | 在线观看亚洲精品 | 爱逼av| 潘金莲一级淫片免费放动漫 | 无码人妻精品一区二区三区不卡 | 性做久久 | 亚洲一区二区精品视频 | 欧美猛交xxx | 黄色一级大片在线免费看产 | www国产亚洲精品 | 日本视频三区 | 久久久久久久久久av | 精品一区二区三区不卡 | 亚洲欧美日韩国产一区二区 | 大肉大捧一进一出好爽mba | 亚洲视频精品一区 | 三上悠亚影音先锋 | 天天色综合久久 | 2020狠狠干 | 亚洲精品视频国产 | 69影院少妇在线观看 | 2019av视频| 中文字幕一区二区人妻电影丶 | 少妇人妻综合久久中文字幕 | 亚洲永久在线观看 | 美女免费网站 | 最近免费中文字幕大全免费版视频 | 午夜激情男女 | 国产 欧美 日韩 在线 | 风韵丰满熟妇啪啪区老熟熟女 | 毛片毛片毛片毛片毛片毛片 | 人人99 | 男生和女生靠逼视频 | 国产欧美专区 | 最新国产视频 | 麻豆91在线观看 | 亚洲国产黄色片 | 免费黄色在线播放 | 欧美9999| 91快射 | 免费在线网站 | 潘金莲一级淫片aaaaaaa | 亚洲国产精品免费视频 | av播放在线 | 美女被草出水 | 国产精品va无码一区二区三区 | 国产在线观看www | 国产免费内射又粗又爽密桃视频 | 中文字幕无线码一区 | 123毛片| 熟妇人妻中文字幕无码老熟妇 | 成人激情视频网 | 亚洲一一在线 | av先锋影音 | 久热在线 | 美女破处视频 | 五月天啪啪 | 欧美日韩有码 | 男人天堂色 | 最新视频–x99av | 污污视频免费网站 | www午夜视频 | 欧美成人aaaa | 日本亚洲综合 | www久久久久久久 | 国产无遮挡免费观看视频网站 | 一级二级av| 欧美激情图片 | 国产精品毛片久久 | 亚洲熟妇国产熟妇肥婆 | 久久久wwww| 亚洲色偷偷综合亚洲av伊人 | 日本少妇吞精囗交视频 | 777免费视频 |