博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Sicily 1299 Academy Awards (map + vector)集装箱
阅读量:5112 次
发布时间:2019-06-13

本文共 3647 字,大约阅读时间需要 12 分钟。

链接:

Description

Selected from 3,850 teams from 1,329 universities in 68 countries competing at 106 sites and preliminary contests worldwide, sixty-eight teams competed for bragging rights and prizes at The 27th Annual ACM International Collegiate Programming Contest World Finals sponsored by IBM on March 25, 2003, in Hollywood, California. The 2003 World Champion is Warsaw University . And Zhongshan University won the 8th place. During those days, another world famous event was held in the same place. It was the 75th Annual Academy Awards. It’s also known as Oscar.

   We always say that the Best Picture is the most important award of all the awards. Before the Oscar Night, we can’t tell which film will win Best Picture. Fortunately, we can dope it out from the Nominee List of all the awards other than the Best Picture. I suggest that you should follow my 3 rules here. 

l         All the films in the list have chances to win the Best Picture

l         The film which will win the Best Picture is the film which has been nominated the most times in the list

l         If there are more than one film which have been nominated the most times in the list, we will choose the first one which appears in the list

 Let’s see such a List below.  

VISUAL EFFECTS

 THE LORD OF THE RINGS: THE TWO TOWERS

SPIDER-MAN

STAR WARS EPISODE II ATTACK OF THE CLONES

 SOUND EDITING  

THE LORD OF THE RINGS: THE TWO TOWERS

MINORITY REPORT

ROAD TO PERDITION

       From the list, we can find that THE LORD OF THE RINGS: THE TWO TOWERS has been nominated twice. And each of the other films has been nominated only once. So we can say THE LORD OF THE RINGS: THE TWO TOWERS will win the Best Picture. 

Your task is to write a program to figure out the anticipatory winner from the list.

Input

The input file will consist of several lists. The first line of each list contains only one integer n (1≤n≤100), representing the number of awards in the list. Then you get n blocks. Each block indicated the nominees of a distinct award. The first line of each block is the name of the award which is not longer than 80. The second line is mi (1≤mi≤10, 1≤i≤n) - the number of nominated films. In the following lines are mi film names, one per line. For make the question simple, you can assume that there isn’t any space in the film names.

 

The input is terminated by a line with one zero.

Output

For each list, you are supposed to figure out the winner of Best Picture in a single line.

Sample Input
 Copy sample input to clipboard
2VISUAL_EFFECTS3THE_LORD_OF_THE_RINGS:_THE_TWO_TOWERSSPIDER-MANSTAR_WARS_EPISODE_II_ATTACK_OF_THE_CLONESSOUND_EDITING3THE_LORD_OF_THE_RINGS:_THE_TWO_TOWERSMINORITY_REPORTROAD_TO_PERDITION0
Sample Output
THE_LORD_OF_THE_RINGS:_THE_TWO_TOWERS

分析: 统计出现频率最高的电影名字。看一下数据范围都不大,时间复杂度为O(n*m), 统计频率用map容器就能够搞定,可是另一个重要的问题就是,题目中要求电影的顺序,所以没办法啦,加一个vector 就OK啦。

。。

代码例如以下:

#include 
#include
#include
#include
#include
#include
#include
#include
#define RST(N)memset(N, 0, sizeof(N))using namespace std;vector
v; map
mp;map
:: iterator it;string award, file, flag; //奖项名字,电影名字,出现频率最高的电影名字;int n, m; //奖项数,获得每一个奖项的电影名字总数;int main(){ while(cin >> n && n) { mp.clear(), v.clear(); //初始化容器。 while(n--) { cin >> award; cin >> m; for(int i=0; i
> file; v.push_back(file); it = mp.find(file); //找到该电影出如今map容器中的位置; if(it != mp.end()) mp[file]++; //找到,频率加1; else mp[file] = 1; //未找到,频率为1;并加到map容器其中; } } int max = 0; for(int i=0; i
second > max) { max = it->second; flag = it->first; } } cout << flag << endl; } return 0;}

版权声明:本文博客原创文章,博客,未经同意,不得转载。

转载于:https://www.cnblogs.com/bhlsheji/p/4741953.html

你可能感兴趣的文章
Android打包key密码丢失找回
查看>>
VC6.0调试技巧(一)(转)
查看>>
类库与框架,强类型与弱类型的闲聊
查看>>
webView添加头视图
查看>>
php match_model的简单使用
查看>>
在NT中直接访问物理内存
查看>>
Intel HEX 文件格式
查看>>
SIP服务器性能测试工具SIPp使用指导(转)
查看>>
回调没用,加上iframe提交表单
查看>>
(安卓)一般安卓开始界面 Loding 跳转 实例 ---亲测!
查看>>
Mysql 索引优化 - 1
查看>>
LeetCode(3) || Median of Two Sorted Arrays
查看>>
大话文本检测经典模型:EAST
查看>>
待整理
查看>>
一次动态sql查询订单数据的设计
查看>>
C# 类(10) 抽象类.
查看>>
Vue_(组件通讯)子组件向父组件传值
查看>>
jvm参数
查看>>
我对前端MVC的理解
查看>>
Silverlight实用窍门系列:19.Silverlight调用webservice上传多个文件【附带源码实例】...
查看>>