【poj2001】Shortest Prefixes
来源:互联网 发布:java调取webservice 编辑:程序博客网 时间:2024/06/05 05:31
#include<iostream>#include<cstdio>using namespace std;char a[1001][21];int tot,size,sz,t[300001][26],s[300001];void insert(char ch[]){int k,len=strlen(ch+1),now=0;for(int p=1;p<=len;p++){k=ch[p]-'a';if(!t[now][k])t[now][k]=++sz;now=t[now][k];s[now]++;}}void ask(char ch[]){int k,len=strlen(ch+1),now=0;for(int p=1;p<=len;p++){if(s[now]==1)break;k=ch[p]-'a';printf("%c",ch[p]);now=t[now][k];}}int main(){while(scanf("%s",a[++tot]+1)!=EOF)insert(a[tot]);for(int i=1;i<=tot;i++){printf("%s ",a[i]+1);ask(a[i]);printf("\n");}return 0;}
0 0
- POJ2001 Shortest Prefixes
- poj2001 Shortest Prefixes
- 【poj2001】Shortest Prefixes
- POJ2001--Shortest Prefixes
- poj2001 Shortest Prefixes
- poj2001 Shortest Prefixes
- POJ2001 Shortest Prefixes
- poj2001 Shortest Prefixes
- 【POJ2001】Shortest Prefixes
- POJ2001[Shortest Prefixes]--Trie
- POJ2001-Shortest Prefixes
- POJ2001 - Shortest Prefixes - 字典树
- POJ2001——Shortest Prefixes
- POJ2001 Shortest Prefixes【字典树】
- 【poj2001】Shortest Prefixes 字典树
- POJ2001 Shortest Prefixes(字典树)
- poj2001 Shortest Prefixes (trie树)
- poj2001 Shortest Prefixes trie树
- 记录我的第一场笔试和电话面试
- Android 常用URI
- 涨水问题 (简单几何+二分查找)
- 浏览器探究——多窗口
- C++虚表
- 【poj2001】Shortest Prefixes
- error:LINK fatal error LNK1123 转换到 COFF 期间失败: 文件无效或损坏
- DoG (Difference of Gaussian)角点检测
- 【bzoj2761】[JLOI2011]不重复数字
- 百度贴吧10亿量级LAMP架构分享
- 观察者模式
- 浏览器探究——下载
- poj 3083 Children of the Candy Corn(dfs+bfs)
- 搞ACM的伤不起啊!!