2015‘12杭电校赛1008 Study Words(map,vector瞎搞)
来源:互联网 发布:服务器监控软件 免费 编辑:程序博客网 时间:2024/05/22 03:17
题解:
有中文输入吓了一跳,不过强行各种STL开搞!
代码
#include <bits/stdc++.h>#include <cstdio>#include <queue>#include <cstring>#include <iostream>#include <cstdlib>#include <algorithm>#include <vector>#include <map>#include <set>#include <ctime>#include <cmath>#include <cctype>#include <string>#include <bitset>#define MAX 100000#define LL long longusing namespace std;int cas=1,T,n;char word[110];int main(){ // freopen("in","r",stdin); scanf("%d",&T); while(T--) { scanf("%*s"); set<string>old; map<string,int>news; old.clear(); news.clear(); while(scanf("%s",word)&&word[0]!='<') { for(int i=0;word[i];i++) word[i]=tolower(word[i]);// puts(word); old.insert(word); } scanf("%*s"); char c,flag=0,i=0; while(c=getchar()) { if(c=='<') break; if(isalpha(c)) { c=tolower(c); word[i++]=c; flag=1; } else if(flag) { word[i]=0;// puts(word); i=flag=0; if(old.count(word)) continue; news[word]++; } } scanf("%*s"); for(int i=0;i<10&&!news.empty();i++) { string maxs; int maxt=0; for(map<string,int>::iterator it=news.begin();it!=news.end();it++) { if(maxt<it->second||maxt==it->second&&maxs > it->first) { maxt=it->second; maxs=it->first; } } cout<<maxs<<endl; news.erase(maxs); } puts(""); } //printf("time=%.3lf\n",(double)clock()/CLOCKS_PER_SEC); return 0;}
题目
Study Words
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 267 Accepted Submission(s): 97
Problem Description
Learning English is not easy, vocabulary troubles me a lot.
One day an idea came up to me: I download an article every day, choose the 10 most popular new words to study.
A word’s popularity is calculated by the number of its occurrences.
Sometimes two or more words have the same occurrences, and then the word with a smaller lexicographic has a higher popularity.
Input
T in the first line is case number.
Each case has two parts.
< oldwords >
…
< /oldwords >
< article >
…
< /article >
Between and are some old words (no more than 10000) I have already learned, that is, I don’t need to learn them any more.
Words between and contain letters (‘a’~’z’,’A’~’Z’) only, separated by blank characters (’ ‘,’\n’ or ‘\t’).
Between
Only continuous letters (‘a’~’z’,’A’~’Z’) make up a word. Thus words like “don’t” are regarded as two words “don” and “t”, that’s OK.
Treat the uppercase as lowercase, so “Thanks” equals to “thanks”. No words will be longer than 100.
As the article is downloaded from the internet, it may contain some Chinese words, which I don’t need to study.
Output
For each case, output the top 10 new words I should study, one in a line.
If there are fewer than 10 new words, output all of them.
Output a blank line after each case.
Sample Input
2
how aRe you
–How old are you?
–Twenty.
google cn huluobo net i
文章内容:
I love google,dropbox,firefox very much.
Everyday I open my computer , open firefox , and enjoy surfing on the inter-
net.
But these days it’s strange that searching “huluobo” is unavail-
able.
What’s wrong with “huluobo”?
Sample Output
old
twenty
firefox
open
s
able
and
but
computer
days
dropbox
enjoy
- 2015‘12杭电校赛1008 Study Words(map,vector瞎搞)
- 2015.12杭电校赛 1008 Study Words
- 计算机学院大学生程序设计竞赛(2015’12)Study Words
- HDU计算机学院大学生程序设计竞赛(2015’12)1008 Study Words
- Words study
- 【杭电2015年12月校赛H】【模拟 STL-MAP STL-SET stringstream】Study Words 从article中提取中10个没有学过的频率最高单词
- daily words(Study English)
- technical words study
- Words from Study
- HDU 5738 Eureka(map瞎搞)
- UVa11991(map+vector)
- 10391 - Compound Words(stl map)
- STL(vector, map, stack)
- gym 100430 G【贪心+map瞎搞】
- poj1850 Code (瞎搞)
- 瞎搞
- 瞎搞
- vector?map?
- UC/OS-II基础知识之事件控制块及事件处理函数
- Struts2防止表单重复提交
- 数字图像处理的就业前景与学习资源
- 程序设计——基于多路并发引擎的高性能C++服务端开发
- 如何在RedHat里面编译R源码并安装
- 2015‘12杭电校赛1008 Study Words(map,vector瞎搞)
- Jar包版本信息
- 关于fedora14更换主板后或ghost系统后网络无法连接的解决办法
- 欢迎使用CSDN-markdown编辑器
- 实现QQ第三方登录、网站接入
- 对数据库的恢复技术的认识
- 几种大数据框架的对比
- 一句话木马上传常见的几种方法
- go语言(一):go 1.6安装