Time Limit:1000MS     Memory Limit:32768KB

Description

Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges' favorite time is guessing the most popular problem. When the contest is over, they will count the balloons of each color and find the result.

This year, they decide to leave this lovely job to you.

Input

Input contains multiple test cases. Each test case starts with a number N (0 < N <= 1000) -- the total number of balloons distributed. The next N lines contain one color each. The color of a balloon is a string of up to 15 lower-case letters.

A test case with N = 0 terminates the input and this test case is not to be processed.

Output

For each case, print the color of balloon for the most popular problem on a single line. It is guaranteed that there is a unique solution for each test case.

Sample Input

5

green

red

blue

red

red

3

pink

orange

pink

0

Sample Output

red

pink

以下是代码:

#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <map>//使用字典容器
#include <string>
using namespace std;
int main(){
int n,k,cnt[1005];
char str[100];
string t;
while(scanf("%d",&n)!=EOF && n){
map<string,int>ball;
map<string, int>::iterator it;
k=1;
for(int i=0;i<1005;cnt[i]=1,i++);
for(int i=0;i<n;i++){
scanf("%s",str);
t = str;
if(ball.count(t))cnt[ball[t]]++;//存在,数量加一
else ball[t]=k++;//不存在,将颜色映射为数字
}
int maxn=1;
for(int i=2;i<n;i++)
if(cnt[i]>cnt[maxn])maxn=i;
for(it = ball.begin();it!=ball.end();it++)
if(it->second == maxn){
cout << it->first<<endl;
break;
}
ball.clear();
}
}

  

Winter-1-E Let the Balloon Rise 解题报告及测试数据的更多相关文章

  1. hdu 1004 Let the Balloon Rise 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1004 用STL 中的 Map 写的 #include <iostream> #includ ...

  2. sgu 104 Little shop of flowers 解题报告及测试数据

    104. Little shop of flowers time limit per test: 0.25 sec. memory limit per test: 4096 KB 问题: 你想要将你的 ...

  3. Spring-2-H Array Diversity(SPOJ AMR11H)解题报告及测试数据

    Array Diversity Time Limit:404MS     Memory Limit:0KB     64bit IO Format:%lld & %llu   Descript ...

  4. Spring-2-J Goblin Wars(SPOJ AMR11J)解题报告及测试数据

    Goblin Wars Time Limit:432MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Description Th ...

  5. Spring-2-B Save the Students(SPOJ AMR11B)解题报告及测试数据

    Save the Students Time Limit:134MS     Memory Limit:0KB     64bit IO Format:%lld & %llu   Descri ...

  6. Spring-2-A Magic Grid(SPOJ AMR11A)解题报告及测试数据

    Magic Grid Time Limit:336MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Description Tha ...

  7. Spring-1-I 233 Matrix(HDU 5015)解题报告及测试数据

    233 Matrix Time Limit:5000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Descript ...

  8. Spring-1-H Number Sequence(HDU 5014)解题报告及测试数据

    Number Sequence Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Pro ...

  9. Spring-1-F Dice(HDU 5012)解题报告及测试数据

    Dice Time Limit:1000MS     Memory Limit:65536KB Description There are 2 special dices on the table. ...

随机推荐

  1. unity导弹算法 预计目标点

    关于导弹的飞行算法,网上有很多教程.简单算法无非是获取目标点的当前位置,然后导弹朝目标方向移动.高深点的,就是通过计算获取碰撞点然后朝着目标移动.如果你能看懂这个高深算法的话,可以去看原帖:http: ...

  2. Unknown SSL protocol error in connection to xxx:443

    使用git从远程下载时,出现Unknown SSL protocol error in connection to xxx:443 错误. 很有可能是被墙在了外面,这里针对墙在外面的情况. 设置代理服 ...

  3. 使用typescript开发react应用

    初始化 mkdir project-dir cd project-dir yarn init -y 安装依赖 yarn add react react-dom yarn add -D typescri ...

  4. 如何通过Keil将程序正确的下载进flash中

    前面介绍了一些创建工程和调试的基本步骤,在这里准备介绍一下如何正确的将Keil程序在仿真调试中下载到flash.这里再次涉及到了debug的窗口.   工具/原料   Keil uVision 4/5 ...

  5. JSP小例子——实现用户登录小例子(不涉及DB操作)

    实现用户登录小例子用户名和密码都为"admin",登陆成功使用服务器内部转发到login_success.jsp页面,并且提示登陆成功的用户名.如果登陆失败则请求重定向到login ...

  6. 五款超实用的开源 SVG 工具

    英文链接:Idrsolutions SVG(Scalable Vector Graphics)是基于 XML 的矢量图像格式,用户可灵活运用图像进行搜索.索引.脚本以及压缩(来自:湖北教育考试网).S ...

  7. ios 更改UITableview中Section的字体颜色

    -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UILabel *c ...

  8. c# winform 应用程序根据条件阻止窗口关闭

    //添加窗口关闭事件委托 在窗口关闭事件中处理 private void TestForm_FormClosing(object sender, FormClosingEventArgs e) { s ...

  9. mysql 标点符号

    w攻防一体化.

  10. jumpserver(0.3.2版本)开源跳板机系统部署

    1. 介绍 JumpServer亮点: 集成Ansible,批量执行命令: 支持WebTerminal wiki地址:https://github.com/jumpserver/jumpserver/ ...