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. 浅谈AutoResetEvent的用法

    using System;using System.Threading; namespace AutoResetEvent_Examples{    class MyMainClass    {    ...

  2. 调用组件的C++代码

    #include<stdio.h>#include "LJSummary.h"#include<iostream>int main(void){ print ...

  3. 在线制作logo

    logoko:http://www.logoko.com.cn/ markmarker:http://emblemmatic.org/markmaker/#/ logomaker:https://lo ...

  4. ProcessBuilder执行本地命令

    /**关键技术剖析 * 用本命令名和命令的参数选项构造ProcessBuilder对象,它的start方法执行命令,启动一个进程,返回一个Process对象 * ProcessBuilder的envi ...

  5. phpcms V9内容页调用标签

    1.页面标题:{$title} 2.发表时间:{$inputtime} 3.内容来源:{$copyfrom} 4.文章内容:{$content} 5.缩略图地址:{$thumb} 6.组图列表: {l ...

  6. anguglar 2+ md5加密

    1.安装 npm install ts-md5 --save 2.使用 import {Md5} from "ts-md5/dist/md5"; constructor() {co ...

  7. fieldmeta 基于springboot的字段元数据管理,通用代码生成,快速开发引擎

    fieldmeta: 基于springboot的字段元数据管理 version:Alpha 0.0.1 ,码云地址:https://gitee.com/klguang/fieldmeta 元数据(Me ...

  8. Linux下查看mysql路径

    ps -ef|grep mysql

  9. ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv opti on so it cannot exe

    Mysql导入csv文件时报错:ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv opti on ...

  10. 使用Ansible自动配置Nginx服务

    1.首先安装好Ansible环境,具体步骤请见Ansible安装 2.先创建hosts文件(为后面编写脚本安装JDK做铺垫) [root@localhost /]# vi hosts [jdktest ...