学会奖章
2014-06-02 21:18
155 查看
Problem 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.
1 All the films in the list have chances to win the Best Picture
2 The film which will win the Best Picture is the film which has been nominated the most times in the list
3 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
2
VISUAL_EFFECTS
3
THE_LORD_OF_THE_RINGS:_THE_TWO_TOWERS
SPIDER-MAN
STAR_WARS_EPISODE_II_ATTACK_OF_THE_CLONES
SOUND_EDITING
3
THE_LORD_OF_THE_RINGS:_THE_TWO_TOWERS
MINORITY_REPORT
ROAD_TO_PERDITION
0
Sample Output
THE_LORD_OF_THE_RINGS:_THE_TWO_TOWERS
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.
1 All the films in the list have chances to win the Best Picture
2 The film which will win the Best Picture is the film which has been nominated the most times in the list
3 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
2
VISUAL_EFFECTS
3
THE_LORD_OF_THE_RINGS:_THE_TWO_TOWERS
SPIDER-MAN
STAR_WARS_EPISODE_II_ATTACK_OF_THE_CLONES
SOUND_EDITING
3
THE_LORD_OF_THE_RINGS:_THE_TWO_TOWERS
MINORITY_REPORT
ROAD_TO_PERDITION
0
Sample Output
THE_LORD_OF_THE_RINGS:_THE_TWO_TOWERS
#include<iostream> #include<string> using namespace std; struct Picture { string name;//该picture的名称 int num;//该picture出现的次数 }picture[1010]; int main() { //freopen("b.txt","r",stdin); int n,m; while(cin>>n&&n) { int i,total=0; string award_name,picture_name; while(n--) { cin>>award_name; cin>>m; while(m--) { cin>>picture_name; for(i=0;i<total;i++)//在0到total之间找当前picture是否已经存在 { if(picture[i].name==picture_name)//如果已经存在,则把它的值加1 { picture[i].num++; } } if(i==total)//i==total表示遍历了0到total之间的所有元素都没找到该picture, { picture[total].name=picture_name;//把picture放到total这个位置 picture[total].num=1; total++;//picture的总数+1 } } } int Max=0; string str; for(i=0;i<total;i++)//找到出现次数最多的picture, { //cout<<picture[i].name<<endl; if(picture[i].num>Max) { Max=picture[i].num; str=picture[i].name; } } cout<<str<<endl; } return 0; }
相关文章推荐
- 学会奖章问题
- 三步学会Java Socket编程
- 一步步学会使用SeaJS(转)
- 要想写出好的企业营销软文学会这三点很关键。
- iOS 教你1分钟学会傻瓜式的GitHub项目托管
- 一步一步学会puppet(三)--节点和模板
- 技术人员应真正学会的第二课程
- 15天学会jquery
- 30分钟学会Ajax编程
- vb.net版机房收费——助你学会七层架构(二)反射+抽象工厂
- 看名言后的心得体会学会融会贯通
- 手把手教你学会 Emacs 定制
- 寒城攻略:Listo 教你 25 天学会 Swift 语言 - 04 Basic Operators
- 寒城攻略:Listo 教你 25 天学会 Swift 语言 - 20 Type Casting
- 黑马程序员 (ARC)内存管理总结 ----- 我这是学会了嘛
- 最大开源项目:玩游戏就能学会编程
- 七天学会NodeJS
- 职场分享:学会管理我们的时间
- 十天学会php之第九天
- CSS3的应用,你学会了吗?