hdu1247 Hat’s Words
来源:互联网 发布:大音希声大象无形 知乎 编辑:程序博客网 时间:2024/06/05 15:23
Hat’s Words
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 11867 Accepted Submission(s): 4225
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
Author
戴帽子的
Recommend
Ignatius.L | We have carefully selected several similar problems for you: 1298 1800 2846 2222 1711
代码:
#include<cstdio>#include<iostream>#include<cstring>#include<string>#include<set>using namespace std;const int maxn=5e4;string s[maxn+5];set<string> q;int main(){ //freopen("1.in","r",stdin); string s1,s2; int n,i,j,k; for(n=0;cin>>s[n];n++)q.insert(s[n]); for(i=0;i<n;i++) for(s1="",k=s[i].length(),j=0;j<k;j++) { s1+=s[i][j],s2=s[i].substr(j+1); if(q.find(s1)!=q.end() && q.find(s2)!=q.end()) { cout<<s[i]<<endl; break; } } return 0;}
0 0
- hdu1247 Hat’s Words
- HDU1247 Hat’s Words
- hdu1247 Hat’s Words
- hdu1247 hat's words
- hdu1247 Hat’s Words
- hdu1247 Hat’s Words
- hdu1247 Hat’s Words
- hash hdu1247 Hat’s Words
- HDU1247 Hat’s Words【Trie】
- Hat's Words hdu1247 trie
- 【字典树】 hdu1247 Hat’s Words
- Hat’s Words hdu1247 字典树+搜索
- HDU1247-Hat’s Words(字典树)
- Hat’s Words(hdu1247字典树)
- hdu1247 Hat’s Words (字典树)
- hdu1247 Hat’s Words(字典树)
- HDU1247-Hat’s Words(trie树)
- HDU1247 Hat’s Words 【trie树】
- JBPM6 - helloworld^_^
- google group翻译(1)
- Thrift
- Java基础:包装类
- C++/MFC修行之路(2) 自定义消息
- hdu1247 Hat’s Words
- 来自Uber的12条架构重构经验
- mybatis+jstl表达式
- ECC-椭圆曲线密码
- SLAM: Ubuntu16.04安装ROS-kinetic
- 统计学总结之Bias(偏差),Error(误差),和Variance(方差)的区别
- 单向链表特点实现
- Ubuntu 15.10配置OpenCV
- pxe网络安装操作系统 原理与详细过程