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. vs2005做的留言本——天轰川下载

    原文发布时间为:2008-08-01 -- 来源于本人的百度文章 [由搬家工具导入] 这个虽然单纯是个留言本,但是在功能上我都使用了尽量不重复的解决方法,所以我自认为非常适合入门级的朋友看,而且用了我 ...

  2. [C++] 频谱图中 FFT快速傅里叶变换C++实现

    在项目中,需要画波形频谱图,因此进行查找,不是很懂相关知识,下列代码主要是针对这篇文章. http://blog.csdn.net/xcgspring/article/details/4749075 ...

  3. 强大的stringstream

    [本文来自]http://www.builder.com.cn/2003/0304/83250.shtmlhttp://www.cppblog.com/alantop/archive/2007/07/ ...

  4. String的引用传递

    一 引用传递的三个范例 范例一 package com.mtzsoft; /** * 范例一 * * @author Administrator * */ public class Test1 { p ...

  5. BZOJ3786 星际探索

    @(BZOJ)[DFS序, Splay] Description 物理学家小C的研究正遇到某个瓶颈. 他正在研究的是一个星系,这个星系中有n个星球,其中有一个主星球(方便起见我们默认其为1号星球),其 ...

  6. Maven学习在Elipse中发布一个Maven项目到Tomcat

    原文:http://www.cnblogs.com/quanyongan/archive/2013/04/26/3044618.html 对于maven初学者的我,经常遇到一个问题就是,maven项目 ...

  7. Go --- GC优化经验

    不想看长篇大论的,这里先给个结论,go的gc还不完善但也不算不靠谱,关键看怎么用,尽量不要创建大量对象,也尽量不要频繁创建对象,这个道理其实在所有带gc的编程语言也都通用. 想知道如何提前预防和解决问 ...

  8. 我的javascript

    JavaScript的简介: 1.定义:javascript是一门动态弱类型的解释型编程语言,增强页面动态效果,实现页面与用户之间的实时动态的交互. javascript是由三部分组成:ECMAScr ...

  9. 【iOS】系统框架学习

    iOS的系统架构分为四个层次:核心操作系统层(Core OS layer).核心服务层(Core Services layer).媒体层(Media layer)和可触摸层(Cocoa Touch l ...

  10. 模拟 nbut1225 NEW RDSP MODE I

    传送门:点击打开链接 题意:输入n.m,x.刚開始有一个1~n的排列.然后定义了一种操作.是将数组中的偶数位数字选出来,依照顺序放到数组最前面,奇数位依照顺序放到偶数位的后面,进行m次这种操作.输出之 ...