Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 9968   Accepted: 4774

Description

In millions of newspapers across the United States there is a word game called Jumble. The object of this game is to solve a riddle, but in order to find the letters that appear in the answer it is necessary to unscramble four words. Your task is to write a program that can unscramble words.

Input

The input contains four parts: 1) a dictionary, which consists of at least one and at most 100 words, one per line; 2) a line containing XXXXXX, which signals the end of the dictionary; 3) one or more scrambled 'words' that you must unscramble, each on a line by itself; and 4) another line containing XXXXXX, which signals the end of the file. All words, including both dictionary words and scrambled words, consist only of lowercase English letters and will be at least one and at most six characters long. (Note that the sentinel XXXXXX contains uppercase X's.) The dictionary is not necessarily in sorted order, but each word in the dictionary is unique.

Output

For each scrambled word in the input, output an alphabetical list of all dictionary words that can be formed by rearranging the letters in the scrambled word. Each word in this list must appear on a line by itself. If the list is empty (because no dictionary words can be formed), output the line "NOT A VALID WORD" instead. In either case, output a line containing six asterisks to signal the end of the list.

Sample Input

tarp
given
score
refund
only
trap
work
earn
course
pepper
part
XXXXXX
resco
nfudre
aptr
sett
oresuc
XXXXXX

Sample Output

score
******
refund
******
part
tarp
trap
******
NOT A VALID WORD
******
course
****** 题意:用XXXXXX表示文本输入部分结束和查询部分结束;如果如果查询的一个单词和输入的单词字母组成一样;输出文本部分所用符合的单词;每查询一次输出*******分隔 题解:一个单词不管怎么排列,经过排序之后的形式一定是一样的,用排序之后的单词作为键值,用map匹配
#include<iostream>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<map>
#include<set>
#define ll long long
using namespace std;
map<string,string>m;
string s,ss;
int n;
int main()
{
int flag=;
while(flag!=)
{
cin>>s;
if(s[]=='X')
{
flag++;
continue;
}
if(flag==)
{
ss=s;
sort(ss.begin(),ss.end());
m[s]=ss; }
if(flag==)
{
int flag2=;
sort(s.begin(),s.end());
map<string,string>::iterator it;
for(it=m.begin();it!=m.end();it++)
{
if(it->second==s)
{
flag2=;
cout<<it->first<<endl;
}
}
if(flag2==)
cout<<"NOT A VALID WORD"<<endl;
cout<<"******"<<endl;
}
} return ; }

poj 1318 Word Amalgamation的更多相关文章

  1. Word Amalgamation(枚举 + 排序)

    Word Amalgamation Time Limit: 1 Sec  Memory Limit: 64 MB Submit: 373  Solved: 247 Description In mil ...

  2. hdu-----(1113)Word Amalgamation(字符串排序)

    Word Amalgamation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  3. Word Amalgamation(hdoj1113)

    Word Amalgamation Problem Description In millions of newspapers across the United States there is a ...

  4. hdu1113 Word Amalgamation(详解--map和string的运用)

    版权声明:本文为博主原创文章.未经博主同意不得转载. vasttian https://blog.csdn.net/u012860063/article/details/35338617 转载请注明出 ...

  5. HDOJ.1113 Word Amalgamation(map)

    Word Amalgamation 点我挑战题目 点我一起学习STL-MAP 题意分析 给出字典.之后给出一系列======乱序======单词,要求你查字典,如过这个乱序单词对用有多个有序单词可以输 ...

  6. poj1318 Word Amalgamation 字符串排序(qsort)

    Word Amalgamation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9794   Accepted: 4701 ...

  7. Uva 642 - Word Amalgamation sort qsort

     Word Amalgamation  In millions of newspapers across the United States there is a word game called J ...

  8. poj 1318

    http://poj.org/problem?id=1318 这个题目还是比较水的,不过也可以提升你对字符串的熟悉度以及对一些排序函数和字符函数的使用. 大概的题意就是给你一个字典,这个字典有一些单词 ...

  9. Word Amalgamation

    Problem Description In millions of newspapers across the United States there is a word game called J ...

随机推荐

  1. MessageBox函数

    <Windows程序设计>(第五版)(美Charles Petzold著) https://docs.microsoft.com/zh-cn/windows/desktop/apiinde ...

  2. Spring Boot项目中各配置文件的对比

    application.properties是Spring Boot的全局配置文件,放在src/main/resources目录下或者类路径的/config下,作用是对一些默认配置的配置值进行修改. ...

  3. bfc作用

    作用 1.清浮动 2.不被浮动元素覆盖 3.阻止父子margin传递 触发条件: 1.float不为none 2.position不为static或relative 3.display:inline- ...

  4. Oracle常用命令复习(备考资料)

    Oracle期末考试复习资料,大概的总结了常用的命令,不包括基础理论知识,有的不太考的东西没有整理.资料整理是在有道云笔记里完成的,在这里重新编辑太麻烦了,就附个链接了. 文档:Oracle命令复习2 ...

  5. python3爬虫

    1.爬虫的基本原理讲解 2.Urllib库的基本使用 3.Requests库的基本使用 4.正则的基本使用 5.BeautifulSoup库的使用 6.PyQuery库的使用   √ 7.Seleni ...

  6. 谁才是天朝最厉害的演员?让Python来为你揭晓!

    一.项目背景 上个月笔者的一个同学开了间影视投资公司,出于对创业人员的仰慕和影视投资行业的好奇,我就跟他寒暄了几句,聊天当中他提及到国庆节有部<攀登者>即将上映,预计票房会大好,因为吴京是 ...

  7. JVM 学习笔记 - 带你掌握JVM类加载机制

    前言 往期JVM系列: 精美图文带你掌握 JVM 内存布局 本节主要内容: 类的生命周期 类加载阶段描述 数组类和非数组类在加载阶段的差别 父子类初始化顺序 接口的初始化 JVM如何处理 多线程同时初 ...

  8. dropdownlist select的用法

    <tr>        <td></td>        <td>@Html.DropDownList("ddlSex",@Mode ...

  9. App在iTunes Store上的地址

    之前可以在电脑上的iTunes上直接搜索到适用于iPhone.iPad的App,进而下载ipa或者复制它的URL. 记得从2017年3月开始就没有这个功能了. ==================== ...

  10. 等级保护2.0-oracle