Problem 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
 
Author
WU, Jiazhi
 
Source
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath> using namespace std; struct node
{
node* next[];
bool end;
int num;
node()
{
for(int i = ;i<;i++)
next[i] = NULL;
end = ;
num = ;
}
};
node* root;
char s[],ma[];
int mx;
int insert()
{
int l =strlen(s);
node* k = root;
int i,j;
for(i = ;i<l-;i++)
{
int id = s[i]-'a';
if(k->next[id] == NULL)
{
node* t = new node();
k->next[id] = t;
k = k->next[id];
}
else
{
k = k->next[id];
}
}
int id = s[i]-'a';
if(k->next[id] == NULL)
{
node* t = new node();
t->end = ,t->num = ;
k->next[id] = t;
k = k->next[id];
}
else
{
k = k->next[id];
k->num++;
}
return k->num;
} int main()
{
int n,i,j,k;
while(cin>>n,n)
{
root = new node();
mx = ;
for(i = ;i<n;i++)
{
cin>>s;
int t = insert();
if(mx<t)
{
mx = t;
int l = strlen(s);
for(j = ;j<=l;j++)
ma[j] = s[j];
}
}
cout<<ma<<endl;
}
return ; }

hdu1004Let the Balloon Rise的更多相关文章

  1. STL: HDU1004Let the Balloon Rise

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  2. hdu 1004 Let the Balloon Rise

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  3. Let the Balloon Rise 分类: HDU 2015-06-19 19:11 7人阅读 评论(0) 收藏

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  4. HDU 1004 Let the Balloon Rise map

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  5. HDU1004 Let the Balloon Rise(map的简单用法)

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...

  6. HD1004Let the Balloon Rise

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...

  7. Let the Balloon Rise(map)

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  8. akoj-1073- Let the Balloon Rise

    Let the Balloon Rise Time Limit:1000MS  Memory Limit:65536K Total Submit:92 Accepted:58 Description ...

  9. HDU 1004 Let the Balloon Rise【STL<map>】

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

随机推荐

  1. VLC播放器架构剖析

    VLC采用多线程并行解码架构,线程之间通过单独的一个线程控制所有线程的状态,解码器采用filter模式.组织方式为模块架构 模块简述:libvlc                  是VLC的核心部分 ...

  2. 判断Table表中是否含有某一列

    if (row.Table.Columns.Contains("DealRecord_GiftCost")) {     if (row["DealRecord_Gift ...

  3. 调用打印机Demo

      接口 PrintService 是 DocPrintJob 的工厂.PrintService 描述了打印机的功能,并可查询它来了解打印机支持的属性. Java代码   import java.io ...

  4. Oracle 查看执行计划

    刚刚开始接触Oracle,使用的工具是Sql Developer.在看执行计划的的时候,选中SQL语句,直接F5即可. 但是这里的执行计划不是最终的执行计划,它使用的是 explain for 命令. ...

  5. C++程序设计实践指导1.5求两个整数集合并集改写要求实现

    改写要求1:改写为单链表结构可以对任意长度整数集合求并集 #include <cstdlib> #include <iostream> using namespace std; ...

  6. discuz二次开发笔记(三)------discuz的安装步骤

    下载好discuz的安装包后,解压在自己定义的文件夹里面,将upload里面的文件拷贝出来放到和upload同级的地方,然后删除upload文件夹. 打开浏览器,输入你文件夹的地址:如:http:// ...

  7. BottomSheetBehavior 之 java.lang.IllegalArgumentException: The view is not associated with BottomSheetBehavior

    AndroidRuntime: FATAL EXCEPTION: main Process: me.chunsheng.uberdriver, PID: 13674 java.lang.Runtime ...

  8. windows系统npm如何升级自身

    其实使用npm升级各种插件是很方便的,比如我想升级express框架,使用如下命令 npm update express 如果你的express是全局安装,则 npm update -g expres ...

  9. php.ini 全站,和htaccess web目录 默认头部和尾部 auto_prepend_file

    php.ini ; Automatically add files before PHP document. ; http://php.net/auto-prepend-file auto_prepe ...

  10. jQuery插件jqplot的详细配置说明和渲染器

    jQuery插件jqplot的详细配置说明和渲染器 (2012-08-23 08:57:42) 转载▼ 标签: jqplot 详细配置 渲染器 it 分类: 技术类 jQuery.jqplot插件的官 ...