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. 影响布局的inline-block的空白符的问题

    昨天切页面时,进行布局时,想改变以下方法换换口味,所以就抛弃了float方法,采用了display:inline-block方法,没想到却随之而来的带来了一个想不通的问题,那就是空白.废话不多说,上代 ...

  2. Linux下安装oracle11g

    1.安装环境: Linux:Redhat Enterprise Linux 6.3 64位 Oracle:Oracle Database 11g for Linux x86-64 64位 2.修改操作 ...

  3. Android 轮询之 Service + AlarmManager+Thread (转)

    android中涉及到将服务器中数据变化信息通知用户一般有两种办法,推送和轮询. 消息推送是服务端主动发消息给客户端,因为第一时间知道数据发生变化的是服务器自己,所以推送的优势是实时性高.但服务器主动 ...

  4. 纯Html+Ajax和JSP两者对比的个人理解

    最近写个人web,用jsp+servlet做,突然想到一个问题:html+ajax似乎和jsp实现效果一样:那么,两者到底有什么区别呢? 这里参考老猿的一段话: 全站ajax会维护大量的js代码,如何 ...

  5. USACO Chapter 1 解题总结

    USACO Chapter 1 解题总结 1.1.1 Your Ride Is Here 基本字符串操作,无压力. 1.1.2 Greedy Gift Givers 基础模拟题,弄明白题意,不怕麻烦, ...

  6. #ifndef #define #endif 防止头文件被重复引用

    想必很多人都看过“头文件中的 #ifndef/#define/#endif 防止该头文件被重复引用”.但是是否能理解“被重复引用”是什么意思?是不能在不同的两个文件中使用include来包含这个头文件 ...

  7. hdu 4612 Warm up(无向图Tarjan+树的直径)

    题意:有N个点,M条边(有重边)的无向图,这样图中会可能有桥,问加一条边后,使桥最少,求该桥树. 思路:这个标准想法很好想到,缩点后,求出图中的桥的个数,然后重建图必为树,求出树的最长直径,在该直径的 ...

  8. jquery判断客户端的类型

    针对不同客户端下载链接的页面响应样式不一样,更人性点而已 //匹配客户端类型 var isAndroid = navigator.userAgent.toLowerCase().match(/andr ...

  9. apache AH01630: client denied by server configuration错误解决方法

    今天本来是想要在自己本地搭建一个wamp环境用来做一些代码的测试和框架的学习. 鉴于目前工作的时候用到了php5.5,所以就用了wamp-server V2.5版本,安装完成之后配置虚拟主机一直出现4 ...

  10. px,dp,dip,sp,in,mm,pt详细分析

    px,dp,dip,sp,in,mm,pt详细分析 px   :(pixels),屏幕的像素点,不同的设备显示效果相同,一般我们HVGA代表320x480像素,这个用的比较多. dip  :(devi ...