Compound Words

Time Limit: 5000ms
Memory Limit: 32768KB

This problem will be judged on ZJU. Original ID: 1825
64-bit integer IO format: %lld      Java class name: Main

 
You are to find all the two-word compound words in a dictionary. A two-word compound word is a word in the dictionary that is the concatenation of exactly two other words in the dictionary.

Input

Standard input consists of a number of lowercase words, one per line, in alphabetical order. There will be no more than 120,000 words.

Output

Your output should contain all the compound words, one per line, in alphabetical order.

Sample Input

a
alien
born
less
lien
never
nevertheless
new
newborn
the
zebra

Sample Output

alien
newborn

 

Source

 
解题:好久没写代码 开始脑残了
 
 #include <bits/stdc++.h>
using namespace std;
unordered_set<string>us;
string word[];
int main() {
ios::sync_with_stdio(false);
int tot = ;
while(cin>>word[tot]) us.insert(word[tot++]);
for(int i = ; i < tot; ++i) {
if(word[i].length() > ) {
for(int j = ,len = word[i].length(); j < len; ++j) {
string a = word[i].substr(,j);
string b = word[i].substr(j);
if(us.count(a) && us.count(b)) {
cout<<word[i]<<endl;
break;
}
}
}
}
return ;
}

ZOJ 1825 Compound Words的更多相关文章

  1. ZOJ 1825 compoud words

    题目大意:输入一串递增的单词序列,需要找出符合条件的单词递增输出,条件是:将一个单词拆成左右两个单词后,能在输入中找到这两个单词.例如单词 alien,可以拆成 a 和 lien,而输入中刚好同时有a ...

  2. ZOJ People Counting

    第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ  3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...

  3. 【BZOJ 1061】【Vijos 1825】【NOI 2008】志愿者招募

    http://www.lydsy.com/JudgeOnline/problem.php?id=1061 https://vijos.org/p/1825 直接上姜爷论文... #include< ...

  4. ZOJ 3686 A Simple Tree Problem

    A Simple Tree Problem Time Limit: 3 Seconds      Memory Limit: 65536 KB Given a rooted tree, each no ...

  5. ZOJ Problem Set - 1394 Polar Explorer

    这道题目还是简单的,但是自己WA了好几次,总结下: 1.对输入的总结,加上上次ZOJ Problem Set - 1334 Basically Speaking ac代码及总结这道题目的总结 题目要求 ...

  6. ZOJ Problem Set - 1392 The Hardest Problem Ever

    放了一个长长的暑假,可能是这辈子最后一个这么长的暑假了吧,呵呵...今天来实验室了,先找了zoj上面简单的题目练练手直接贴代码了,不解释,就是一道简单的密文转换问题: #include <std ...

  7. ZOJ Problem Set - 1049 I Think I Need a Houseboat

    这道题目说白了是一道平面几何的数学问题,重在理解题目的意思: 题目说,弗雷德想买地盖房养老,但是土地每年会被密西西比河淹掉一部分,而且经调查是以半圆形的方式淹没的,每年淹没50平方英里,以初始水岸线为 ...

  8. ZOJ Problem Set - 1006 Do the Untwist

    今天在ZOJ上做了道很简单的题目是关于加密解密问题的,此题的关键点就在于求余的逆运算: 比如假设都是正整数 A=(B-C)%D 则 B - C = D*n + A 其中 A < D 移项 B = ...

  9. ZOJ Problem Set - 1001 A + B Problem

    ZOJ ACM题集,编译环境VC6.0 #include <stdio.h> int main() { int a,b; while(scanf("%d%d",& ...

随机推荐

  1. HDU 1465 不容易系列之一( 错排水题 )

    链接:传送门 思路:错排模板题,水题是非常浪费时间的 /************************************************************************ ...

  2. Shell(一)变量

    一.简介 Shell 是一个用 C 语言编写的程序,它是用户使用 Linux 的桥梁.Shell 既是一种命令语言,又是一种程序设计语言. Shell 是指一种应用程序,这个应用程序提供了一个界面,用 ...

  3. Android开发进度01

    1,今日:目标:完成eclipse中Android sdk和ADT的创建,下载tools工具,创建Android虚拟机 2,昨天:无 3,收获:Android sdk manager需要下载的东西:学 ...

  4. 原生JS封装ajax以及request

    一.封装原生的xhr为ajax类 xhr以及用法见之前的文章 1.根据url确定请求的头部以及别的信息. var _headerConfig = {}; if(url.indexOf('getcapt ...

  5. python_函数传递列表

    '''#创建一个空列表,包含一些要打印的设计unprinted_designs = ['iphone','robot','books']completed_modles = [] #模拟打印每个设计, ...

  6. 【henuacm2016级暑期训练-动态规划专题 C】Little Girl and Maximum XOR

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 考虑r最后的二进制形式为 1xxxxx 那么我们肯定想让第一个最高位的1保留. 因此我们选取的另外一个数字 一定是 0xxxxx的形 ...

  7. 洛谷 P2393 yyy loves Maths II

    P2393 yyy loves Maths II 题目背景 上次蒟蒻redbag可把yyy气坏了,yyy说他只是小学生,蒟蒻redbag这次不坑他了. 题目描述 redbag给了yyy很多个数,要yy ...

  8. 洛谷 P3047 [USACO12FEB]附近的牛Nearby Cows

    P3047 [USACO12FEB]附近的牛Nearby Cows 题目描述 Farmer John has noticed that his cows often move between near ...

  9. jquery让 readOnly失效的方法

    re.attr("readOnly","true"); re.attr("readOnly",false); 注意 :false不能带引号

  10. 自己定义控件-MultipleTextView(自己主动换行、自己主动补齐宽度的排列多个TextView)

    一.功能: 1.传入一个 List<String> 数组,控件会自己主动加入TextView,一行显示不下会自己主动换行.而且把上一行末尾的空白通过拉伸而铺满. 2.配置灵活 <co ...