hdu 1247 字典树 Hat’s Words
来源:互联网 发布:软件缺陷报告模板 编辑:程序博客网 时间:2024/05/22 10:37
这个代码不知道为什么AC不了
#include <stdio.h>#include<string.h>#include<stdlib.h>struct trie{int ch;trie *next[26];trie(){ch=0;for(int i=0;i<26;i++)next[i]=NULL;}};trie *root;char str[50010][100];void insert(char *s){trie * p=root;int len=strlen(s);int i;for(i=0;i<len;i++){int num=s[i]-'a';if(!p->next[num])p->next[num]=new trie;p->next[num]->ch=1;p=p->next[num];}}int find(int l,int r,char *s){trie *p=root;for(int i=l;i<r;i++){int num=s[i]-'a';if(!p->next[num])return 0;else p=p->next[num];}return 1;}int main(){if(!root)root=new trie;int k=0;while(gets(str[k])){insert(str[k++]);}for(int i=0;i<k;i++){int len=strlen(str[i]);for(int j=1;j<len;j++){if(find(0,j,str[i])&&find(j,len,str[i])){printf("%s\n",str[i]);break;}}}system("pause");return 0;}
- HDU 1247 Hat’s Words(字典树)
- hdu 1247 字典树 Hat’s Words
- HDU 1247 Hat’s Words 字典树
- hdu 1247 Hat’s Words 字典树
- HDU 1247 Hat’s Words(字典树)
- hdu 1247 Hat’s Words(字典树)
- hdu 1247 Hat’s Words字典树
- hdu 1247 Hat’s Words(字典树)
- hdu 1247 Hat’s Words 字典树
- 【字典树】HDU 1247 Hat’s Words
- HDU--1247:Hat’s Words (字典树)
- hdu 1247 Hat’s Words(字典树)
- [字典树] HDU 1247 - Hat’s Words
- hdu 1247 Hat’s Words (字典树)
- HDU 1247 Hat’s Words 字典树
- HDU - 1247 Hat’s Words(字典树)
- hdu 1247 Hat’s Words 字典树
- hdu 1247 Hat’s Words(字典树)
- BMP格式解析
- 字符串转为整数,不考虑进制
- POJ2785 和为0的组合数(数的哈希)
- altium designer 画箭头
- SQL JOIN TEST
- hdu 1247 字典树 Hat’s Words
- java-基础加强之枚举
- 【Android Training - 05】与其他Apps进行交互 [ Lesson 1 - 启动到另外一个app ]
- 硬盘方式安装redhat7
- Anger Begins&&http://acm.nbut.cn:8081/Contest/view/id/29/problem/A.xhtml
- 走出浮躁的泥沼:关于技术与工作
- 让窗体保持在最顶层实例
- VBS模拟Post上传文件失败
- 立波硬件检测:安卓手机硬件信息详细检测