设为首页 加入收藏

TOP

SWERC13 Trending Topic
2015-07-20 17:50:05 来源: 作者: 【 】 浏览:2
Tags:SWERC13 Trending Topic


map暴力。。。


Imagine you are in the hiring process for a company whose principal activity is the analysis
of information in the Web. One of the tests consists in writing a program for maintaining up to
date a set of trending topics. You will be hired depending on the efficiency of your solution.
They provide you with text from the most active blogs. The text is organised daily and you
have to provide the sorted list of the N most frequent words during the last 7 days, when asked.
INPUT
Each input file contains one test case. The text corresponding to a day is delimited by tag
. Queries of top N words can appear between texts corresponding to two different days.
A top N query appears as a tag like . In order to facilitate you the process of reading
from input, the number always will be delimited by white spaces, as in the sample.
Notes:
? All words are composed only of lowercase letters of size at most 20.
? The maximum number of different words that can appear is 20000.
? The maximum number of words per day is 20000.
? Words of length less than four characters are considered of no interest.
? The number of days will be at most 1000.
? 1 ≤ N ≤ 20
OUTPUT
The list of N most frequent words during the last 7 days must be shown given a query. Words
must appear in decreasing order of frequency and in alphabetical order when equal frequency.
There must be shown all words whose counter of appearances is equal to the word
at position N. Even if the amount of words to be shown exceeds N.


SAMPLE INPUT

imagine you are in the hiring process of a company whose
main business is analyzing the information that appears
in the web


a simple test consists in writing a program for
maintaining up to date a set of trending topics


you will be hired depending on the efficiency of your solution



they provide you with a file containing the text
corresponding to a highly active blog


the text is organized daily and you have to provide the
sorted list of the n most frequent words during last week
when asked


each input file contains one test case the text corresponding
to a day is delimited by tag text


the query of top n words can appear between texts corresponding
to two different days



blah blah blah blah blah blah blah blah blah
please please please


2
Problem IProblem I
Trending Topic
SAMPLE OUTPUT

analyzing 1
appears 1
business 1
company 1
consists 1
date 1
depending 1
efficiency 1
hired 1
hiring 1
imagine 1
information 1
main 1
maintaining 1
process 1
program 1
simple 1
solution 1
test 1
that 1
topics 1
trending 1
whose 1
will 1
writing 1
your 1


text 4
corresponding 3
file 2
provide 2
test 2
words 2


blah 9
text 4
corresponding 3
please 3



#include 
  
   
#include 
   
     #include 
    
      #include 
     
       #include 
      
        #include 
        #include 
        
          using namespace std; typedef pair
         
           pII; map
          
            Hash; vector
           
             dy[11]; string rHash[20200]; int day_sum[11][20200]; char cache[30]; int now=9,pre=0,id=1; int arr[20020],na; string rss[20020]; bool vis[20020]; void DEBUG(int x) { int sz=dy[x].size(); for(int i=0;i
            
             b.times; else return a.word
             
              = sig &&vis[dy[now][i]]==false) { rsp[rn++]=(RSP){times,rHash[dy[now][i]]}; vis[dy[now][i]]=true; } } sort(rsp,rsp+rn,cmpRSP); printf("
              
               \n",k); for(int i=0;i
               
                \n"); } int main() { while(scanf("%s",cache)!=EOF) { if(strcmp(cache,"
                
                 ")==0) { ///read cache pre=now; now=(now+1)%10; dy[now]=dy[pre]; memcpy(day_sum[now],day_sum[pre],sizeof(day_sum[0])); ///7 day ago .... while(scanf("%s",cache)) { if(cache[0]=='<') break; if(strlen(cache)<4) continue; string word=cache; if(Hash[word]==0) { rHash[id]=word; Hash[word]=id++; } int ID=Hash[word]; if(day_sum[pre][ID]==0) dy[now].push_back(ID); day_sum[now][ID]++; } } else if(strcmp(cache,"
                 
                  

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇UVa10986_Sending email(最短路)(.. 下一篇HDU-4937-A simple simulation pr..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·哈希表 - 菜鸟教程 (2025-12-24 20:18:55)
·MySQL存储引擎InnoDB (2025-12-24 20:18:53)
·索引堆及其优化 - 菜 (2025-12-24 20:18:50)
·Shell 中各种括号的 (2025-12-24 19:50:39)
·Shell 变量 - 菜鸟教 (2025-12-24 19:50:37)