UVA11488 字典树模板题
来源:互联网 发布:sd卡数据恢复手机版 编辑:程序博客网 时间:2024/05/29 16:43
https://vjudge.net/problem/UVA-11488
求 前缀*以这个子串为前缀的数目 的最大值。
字典树模板题。
#include <cstdlib>#include <cstdio>#include <iostream>#include <string>#include <cstring>using namespace std;const int AX =5e5+6;int ans;typedef struct Trie_Node{struct Trie_Node* next[2];int count;bool exist;}TrieNode,*Trie;TrieNode* Trie_createroot(){TrieNode* root = new TrieNode();root->count = 0;root->exist = false;memset(root->next,0,sizeof(root->next));return root;}void Trie_insert(Trie node,char* p){int num = 0;while( *p ){num++;if(node->next[*p-'0'] == NULL){node->next[*p-'0'] = Trie_createroot();}node = node->next[*p-'0'];++p;node->count += 1;ans = max( ans , num*node->count ); //只需要再模板上加个取最值判断}node->exist = true;}int main(){ int T; cin>>T; int n; while( T-- ){ ans = 0; char s[201]; scanf("%d",&n); Trie root = Trie_createroot(); for( int i = 0 ; i < n ; i++ ){ scanf("%s",s); Trie_insert(root,s); } printf("%d\n",ans); } return 0;}
阅读全文
0 0
- UVA11488 字典树模板题
- UVA11488 字典树裸题+刘汝佳字典树模板
- Trie树+uva11488
- trie树(uva11488)
- uva11488
- UVa11488
- UVA11488——Hyper Prefix Sets(字典树,最长前缀)
- 字典树模板题&hdu1251
- HDU1671(字典树模板题)
- UVa11488-Hyper Prefix Sets(trie树)
- uva11488 Hyper Prefix Sets(Trie树)
- POJ2001 - 字典树(trie)的模板题
- hdu1251 字典树trie 模板题
- hdu1251-统计难题-字典树模板题
- 字典树模板题(la3942)
- hdu1251统计难题-字典树模板题
- HDU1251(静态维护字典树模板题)
- 字典树 模板
- mfc 对话框 孙鑫 第七章
- CodeForces
- HDU6075(签到水题)
- python学习网站
- 细说UGUI中Anchor和Pivot(一)
- UVA11488 字典树模板题
- 使用脚本刷怪的方法
- IntelliJ IDEA Error running Unnamed:Address localhost:1099 is already in use
- YV12,I420,YUV420P的区别与格式转换
- sourcetree免注册使用
- C# 中的委托和事件
- CSS position 属性讲解
- Lua学习笔记:Lua 中的C Api 概述
- Maven设置将src/main/java下的xml编译到classpath(回应)