hdu1004Let the Balloon Rise
This year, they decide to leave this lovely job to you.
A test case with N = 0 terminates the input and this test case is not to be processed.
green
red
blue
red
red
3
pink
orange
pink
0
pink
#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的更多相关文章
- STL: HDU1004Let the Balloon Rise
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- hdu 1004 Let the Balloon Rise
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- 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 ...
- 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 ...
- HDU1004 Let the Balloon Rise(map的简单用法)
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- HD1004Let the Balloon Rise
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- Let the Balloon Rise(map)
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- akoj-1073- Let the Balloon Rise
Let the Balloon Rise Time Limit:1000MS Memory Limit:65536K Total Submit:92 Accepted:58 Description ...
- 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 ...
随机推荐
- Js触发ASP.NET Validation控件的验证, 同时获取前台验证结果(不包括CustomValidator)
function CallValidate(group) { if (typeof (Page_ClientValidate) == "function") { Page_Bloc ...
- android实现透明和半透明效果
从透明到半透明时一个值的变化过程. #00000000(全透明)——#e0000000(半透明) 如果觉得半透明的效果太暗淡.可以设置成#60000000,#80000000,#a0000000等等
- android开发工具类总结(一)
一.日志工具类 Log.java public class L { private L() { /* 不可被实例化 */ throw new UnsupportedOperationException ...
- Failed to create the Java Virtual Machine (Myeclipse或者eclipse启动报错)
把某几个值改为原来的0.5倍就ok了(我就这么解决的) eclipse.ini如下: -startupplugins/org.eclipse.equinox.launcher_1.2.0.v2 ...
- Visual Studio 使用技巧
整理备用: 1. 键入prop后,连续按两下tab, 可以自动生成属性,然后输入类型和名称. 类似的还有: propg, 生成private set的属性 propfull,生成私有字段,和相应属性 ...
- 【写一个自己的js库】 4.完善跨浏览器事件操作
1.阻止冒泡. function stopPropagation(event){ event = event || getEvent(event); if(event.stopPropagation) ...
- python图片小爬虫
import re import urllib import os def rename(name): name = name + '.jpg' return name def getHtml(url ...
- (译)linux系统关于命令echo的15个例子
15 Practical Examples of ‘echo’ command in Linux By Avishek Kumar Under: Linux Commands On: August 2 ...
- 【LeetCode练习题】Longest Valid Parentheses
Longest Valid Parentheses Given a string containing just the characters '(' and ')', find the length ...
- PHP转码函数
解决中文乱码问题,数据库使用sql server ,是gbk编码,所以在存储和前台显示时都要转码. function cn_convert2web($str){ return iconv('gbk', ...