HDOJ 1247 Hat’s Words
来源:互联网 发布:关于网络利弊 编辑:程序博客网 时间:2024/06/04 17:49
Hat’s Words
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8325 Accepted Submission(s): 3003
Problem Description
A hat’s word is a word in the dictionary that is the concatenation of exactly two other words in the dictionary.
You are to find all the hat’s words in a dictionary.
You are to find all the hat’s words in a dictionary.
Input
Standard input consists of a number of lowercase words, one per line, in alphabetical order. There will be no more than 50,000 words.
Only one case.
Only one case.
Output
Your output should contain all the hat’s words, one per line, in alphabetical order.
Sample Input
aahathathatwordhzieeword
Sample Output
ahathatword
/*HDOJ 1247 查找单词是否是其他2个组成 */#include<iostream>#include<stdio.h>#include<map>#include<string>using namespace std;char str[50001][100];map<string,int> ss;int main(){ int k,k1,k2,i,j; char f[100],e[100]; k=0; // freopen("test.txt","r",stdin); while(scanf("%s",str[k])!=EOF) { ss[str[k]]=5;//表示单词的存在 k++; } for(i=0;i<k;i++) { for(j=0;str[i][j]!='\0';j++)//将单词拆成2部分, { //分别查看是否存在与map中 f[j]=str[i][j];f[j+1]='\0'; if(ss[f]==5)//前一个单词存在 { for(k1=j+1,k2=0;str[i][k1]!='\0';k1++,k2++) e[k2]=str[i][k1]; e[k2]='\0'; if(ss[e]==5) { printf("%s\n",str[i]); break; } } } } return 0;}
0 0
- HDOJ 1247 Hat’s Words
- HDOJ Hat’s Words
- [HDOJ 1247] Hat’s Words [字典树]
- 字典树-HDOJ-1247-Hat’s Words
- hdoj-1247-Hat’s Words-字典树
- HDOJ-1247Hat’s Words(Trie)
- HDOJ 题目1247 Hat’s Words(map)
- HDOJ Hat’s Words 1247【经典字典树】
- HDOJ 1247 Hat’s Words(strncpy函数的运用)
- HDOJ 1247 Hat’s Words(字典树变形)
- (字典树)Hat’s Words -- HDOJ
- HDOJ 1247 -- Hat Words Trie
- hdu 1247 Hat’s Words
- hdu 1247 Hat's words
- hdu 1247 Hat’s Words
- hud-1247-Hat’s Words
- HDU 1247 - Hat’s Words
- hdu 1247 Hat’s Words
- 支撑互联网应用的新兴数据管理结构模型
- oracle服务器和客户端字符集的查看和修改
- Android开发之杂记(2)
- 一张图告诉你,只会jQuery还不够!
- windows下nginx+tomcat集群,实现session复制共享
- HDOJ 1247 Hat’s Words
- opencv 2.4如何读取摄像头的操作
- GIS(四)——为js版搜狗地图添加边界+Marker和Brand的最终美化版
- Android模拟器上不了网的解决办法
- PHPCMS V9调用栏目
- IOS 代码实现自动布局(视图尺寸自动调整)
- 算法————笔试内容--->二叉搜索树
- HDOJ 1251 统计难题 字典树
- 自己写android的关机命令