hdu 1800字典树
来源:互联网 发布:网络自制综艺节目研究 编辑:程序博客网 时间:2024/05/05 05:31
简单的字典树实现
#include<iostream>#include<string>using namespace std;int N, n, Max;string str;char ch;struct node{node* son[10]; int tag;int count;node(){tag = 1;count = 0;for(int i = 0; i < 10; i ++){son[i] = NULL;} }};node* root = new node();void BuildTree(string str){int i;for(i = 0; i < str.length(); i ++){if(str[i] == '0') continue;else break;}node* p = root;for(; i < str.length(); i ++){int s = str[i]-'0';//cout<<s<<endl;if(p->son[s] == NULL) {p->son[s] = new node();}p = p->son[s];p->tag = s;}p->count++;if(p->count > Max) Max = p->count;}void DeleteTree(){root = new node();}int main(){while(cin >> n){Max = 0;DeleteTree();while(n --){cin >> str;BuildTree(str);}cout<<Max<<endl;}return 0;}
0 0
- hdu 1800 字典树
- hdu 1800字典树
- hdu--1800--字典树&&其他
- 字典树 之 hdu 1800
- hdu 1800 字典树或Hash
- hdu 1671 字典树
- hdu 3460 字典树
- hdu 1251(字典树)
- HDU 2846 字典树
- hdu 1251 字典树
- HDU 1251 字典树
- HDU 1671 字典树
- hdu 1247 字典树
- HDU 2846 字典树
- [字典树]hdu 1075
- hdu 1075 字典树
- hdu 1247 字典树
- 字典树 hdu 1075
- Hive学习
- css列表样式
- USACO checker WA code
- HTTP协议1.1版本个人学习总结
- 基于Mahout的电影推荐系统
- hdu 1800字典树
- 复杂系统处理
- 内核里读写文件
- ASP.NET - Exception from HRESULT: 0x80070057 (E_INVALIDARG)
- 印象笔记
- Oracle学习(一):基本操作和基本查询语句
- C++函数参数,返回值,拷贝构造函数等
- Apache提示错误Cannot load php5apache2_2.dll into server的
- 错误总结分析