HDU 1247 Hat’s Words
来源:互联网 发布:plsql导入表数据库 编辑:程序博客网 时间:2024/05/16 02:14
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
直接用map就好了。
#include<map>#include<cstdio>#include<string>#include<cstring>#include<iostream>#include<algorithm>using namespace std;const int maxn = 50005;map<string, int> M;int tot;string s[maxn];int main(){ for (int i = tot = 0; cin >> s[i]; tot++, i++) M[s[i]] = 1; for (int i = 0; i < tot; i++) for (int j = 0; s[i][j]; j++) if (M[s[i].substr(0, j + 1)]) if (M[s[i].substr(j + 1, s[i].size())]) { cout << s[i] << endl; break; }}
0 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 Hat's Words(1247)
- HDU 1247 Hat’s Words
- HDU 1247 Hat’s Words
- hdu 1247 Hat’s Words
- quick-cocos2d-x游戏开发【9】——单点触摸
- 服务器TCP配置
- Nginx 战斗准备:优化指南
- spring mvc前台时间字符串到后台Date的转换
- PostgreSQL的外部表使用
- HDU 1247 Hat’s Words
- hibernate多对多映射
- quick-cocos2d-x游戏开发【10】——触摸捕获事件 cc.NODE_TOUCH_CAPTURE_EVENT
- Android利用画图类和线程画出闪烁心形
- 设计模式---责任链(模拟Servlet的filter)
- gson的@Expose注解和@SerializedName注解
- iOS APP 架构漫谈
- 黑马程序员——OC的三大特性:封装、继承、多态
- 周期数的判断