Study Words

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 195    Accepted Submission(s): 66

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 <oldwords> and </oldwords> 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 <oldwords> and </oldwords> contain letters ('a'~'z','A'~'Z') only, separated by blank characters (' ','\n' or '\t').

Between <article> and </article> is an article (contains fewer than 1000000 characters).

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
<oldwords>
how aRe you
</oldwords>
<article>
--How old are you?
--Twenty.
</article>
<oldwords>
google cn huluobo net i
</oldwords>
<article>
文章内容:
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"?
</article>
 
Sample Output
old
twenty firefox
open
s
able
and
but
computer
days
dropbox
enjoy
 

今天是2015年最后一个星期日,我用了好长好长好长时间做了这道题,测试答案不应该错,可是.........好伤心、

不想再修改了。。。。就让它一直错吧!下面的是正确的答案哦!

#include<cstdio>
#include<cstring>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
int T;
char s[100+10];
char r[100+10];
map<string,int>m;
struct dan
{
char s[100+10];
int num;
}d[1000000+10];
int sum;
int tot;
bool cmp(const dan&a,const dan&b)
{
if(a.num==b.num) return strcmp(a.s,b.s)<0;
return a.num>b.num;
} //转小写
void F()
{
for(int i=0;s[i];i++)
if(s[i]>='A'&&s[i]<='Z')
s[i]=s[i]-'A'+'a';
}
void work()
{
int len=strlen(s);
tot=0;
for(int i=0;i<=len;i++)
{
if(s[i]>='a'&&s[i]<='z') r[tot++]=s[i];
else
{
r[tot]='\0';
if(strlen(r)>0) m[r]=-1;
tot=0;
}
}
}
void work2()
{
int len=strlen(s);
tot=0;
for(int i=0;i<=len;i++)
{
if(s[i]>='a'&&s[i]<='z') r[tot++]=s[i];
else
{
r[tot]='\0';
if(strlen(r)>0)
{
if(m[r]!=-1)
{
if(m[r]==0) strcpy(d[sum++].s,r);
m[r]++;
}
}
tot=0;
}
}
}
int main()
{
scanf("%d",&T);
while(T--)
{
int flag=0;
m.clear();
sum=0;
while(1)
{
scanf("%s",s);
if(strcmp(s,"<oldwords>")==0) {flag=1;continue;}
if(strcmp(s,"</oldwords>")==0) {flag=2;continue;}
if(strcmp(s,"<article>")==0) {flag=3;continue;}
if(strcmp(s,"</article>")==0) break;
if(flag==1)
{
F();
work();
}
if(flag==3)
{
F();
work2();
}
}
for(int i=0;i<sum;i++) d[i].num=m[d[i].s];
sort(d,d+sum,cmp);
for(int i=0;i<min(10,sum);i++) printf("%s\n",d[i].s);
printf("\n");
}
return 0;
}

@执念  "@☆但求“❤”安★下次我们做的一定会更好。。。。



为什么这次的题目是英文的。。。。QAQ...

计算机学院大学生程序设计竞赛(2015’12)Study Words的更多相关文章

  1. hdu 计算机学院大学生程序设计竞赛(2015’11)

    搬砖 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submissi ...

  2. 计算机学院大学生程序设计竞赛(2015’11)1005 ACM组队安排

    1005 ACM组队安排 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Pro ...

  3. 计算机学院大学生程序设计竞赛(2015’12) 1008 Study Words

    #include<cstdio> #include<cstring> #include<map> #include<string> #include&l ...

  4. 计算机学院大学生程序设计竞赛(2015’12)Polygon

    Polygon Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Su ...

  5. 计算机学院大学生程序设计竞赛(2015’12)The Country List

    The Country List Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  6. 计算机学院大学生程序设计竞赛(2015’12) 1009 The Magic Tower

    #include<cmath> #include<cstdio> #include<cstring> #include<algorithm> using ...

  7. 计算机学院大学生程序设计竞赛(2015’12) 1006 01 Matrix

    #include<stdio.h> #include<string.h> #include<iostream> #include<algorithm> ...

  8. 计算机学院大学生程序设计竞赛(2015’12) 1003 The collector’s puzzle

    #include<cstdio> #include<algorithm> using namespace std; using namespace std; +; int a[ ...

  9. 计算机学院大学生程序设计竞赛(2015’12) 1004 Happy Value

    #include<cstdio> #include<cstring> #include<cmath> #include<vector> #include ...

随机推荐

  1. Nova 组件详解

    本节开始,我们将详细讲解 Nova 的各个子服务. 前面架构概览一节知道 Nova 有若干 nova-* 的子服务,下面我们将依次学习最重要的几个.今天先讨论 nova-api 和 nova-cond ...

  2. POJ 2762 Going from u to v or from v to u? Tarjan算法 学习例题

    Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 17104   Accepted: 4594 Description In o ...

  3. Codeforces963D. Frequency of String

    $n \leq 100000$的一文本串,给$m \leq 100000$个询问,每次问一小串在文本串的哪一个最短的子串里出现指定次数.注意,询问串互不相同,且总长度$\leq 100000$. 比赛 ...

  4. Scott Mitchell的ASP.NET2.0数据指南中文版索引

    原文发布时间为:2008-08-03 -- 来源于本人的百度文章 [由搬家工具导入] 原文http://www.cnblogs.com/ilovejolly/archive/2006/10/05/52 ...

  5. excel打乱各行的顺序,实现无序随机排列

    由于公司做活动,经常会发些激活码过来,为了让激活码能够充分使用,经常要打乱激活码的顺序,百度了下,看了下网上的介绍,还不错,挺实用,记录下来. 具体方法如下: 1.将文本里的内容复制到Excel里的任 ...

  6. Codeforces Round #287 (Div. 2) E. Breaking Good [Dijkstra 最短路 优先队列]

    传送门 E. Breaking Good time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  7. unity的List构造函数在IOS平台存在缺陷

    当迩使用一个int[]或者string[]类似的数组时,以数组来初始化List对象,有可能在IOS平台上会出现初始化对象为空,比如 , }; List<int> listTest = ne ...

  8. laravel的视图

    //输出视图 //建立控制器方法public function hello_test(){ return view('member/hello_test',['name'=>'张三','age' ...

  9. 装B技能GET起来!Apple Pay你会用了吗?

    科技圈儿有一个自带光环的品牌 它每次一有任何动静 不用宣传 也不用刻意营销 消息还是能传天下 2月18日 你敢说你的朋友圈儿没有被下面这个词儿刷屏? Apple Pay 这不,我就跟着凑凑热闹,开个小 ...

  10. AC日记——[SDOI2009]晨跑 bzoj 1877

    1877: [SDOI2009]晨跑 Time Limit: 4 Sec  Memory Limit: 64 MBSubmit: 2131  Solved: 1142[Submit][Status][ ...