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. VC++ Splash Window封装类CSplash

    Splash.h 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 ...

  2. ASP.NET MVC 随想录

    http://www.cnblogs.com/OceanEyes/category/696137.html

  3. Git------pull出错解决方法

    1.图片 转载:http://www.2cto.com/os/201404/293183.html

  4. keystore是个嘛东西

    不管是QQ,还是微信,还是支付,涉及到第三方的都的用这个玩意,有时候找不对很坑的 首先我们要区分jks, app,keystore(新建keystoer的文件new就可以了)再进行下一步操作 Ecli ...

  5. [JAVA]基于微信公众平台开放接口编写的sdk

    最近在研究微信公众平台提供的公众服务号,以及提供的开放接口. 写了一个相对来说比较简单的基于java的微信sdk,目前实现的功能没有覆盖所有接口. 有兴趣的话,大家可以在这个基础上进行改进和完善,这样 ...

  6. 五 Android Studio打包Eegret App (包名和签名,打出正式包)

    一 定义包名 如下图,在AndroidManifest.xml中的package就是包名 二 创建keystore 选择Build->Generate Signed APK 选择create n ...

  7. PAT 甲级 1060 Are They Equal

    1060. Are They Equal (25) 时间限制 50 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue If a ma ...

  8. Code Forces 645B Mischievous Mess Makers

    It is a balmy spring afternoon, and Farmer John's n cows are ruminating about link-cut cacti in thei ...

  9. Delphi编写下载程序:UrlDownloadToFile的进度提示

    urlmon.dll中有一个用于下载的API,MSDN中的定义如下: HRESULT URLDownloadToFile(             LPUNKNOWN pCaller,       L ...

  10. Django 翻译与 LANGUAGE_CODE

    LANGUAGE_CODE[1] LANGUAGE_CODE 是 language code 的字符串.格式与 Accept-Language HTTP header 相同,不区分大小写,比如:zh, ...