HDU-1113(map的运用)
Word Amalgamation
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.
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
using namespace std;
#define INF -100000
typedef long long ll;
const int maxn=;
string words,tmp,query;
map<string,string> ans;
int main()
{
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
while(cin>>words){
if(words=="XXXXXX") break;
tmp=words;
sort(words.begin(),words.end());
ans[tmp]=words;
}
while(cin>>query){
if(query=="XXXXXX") break;
int flag=;
sort(query.begin(),query.end());
for(map<string,string>::iterator it=ans.begin();it!=ans.end();it++)
if(it->second==query){
cout<<it->first<<endl;
flag=;
}
if(!flag) printf("NOT A VALID WORD\n");
printf("******\n");
}
return ;
}
HDU-1113(map的运用)的更多相关文章
- HDU 1113 Word Amalgamation (map 容器 + string容器)
http://acm.hdu.edu.cn/showproblem.php?pid=1113 Problem Description In millions of newspapers across ...
- HDOJ/HDU 1113 Word Amalgamation(字典顺序~Map)
Problem Description In millions of newspapers across the United States there is a word game called J ...
- hdu 1113 Word Amalgamation
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1113 字符串简单题: stl水过 如下: #include<algorithm> #inc ...
- hdu - 1113 Word Amalgamation (stl)
http://acm.hdu.edu.cn/showproblem.php?pid=1113 给定一个字典,然后每次输入一个字符串问字典中是否有单词与给定的字符串的所有字母一样(顺序可以打乱),按字典 ...
- hdu 1113 Word Amalgamation 解题报告
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1113 题意:输入一个字典,然后再输入若干单词(每行中,1 <= 单词数 <= 100,并且 ...
- hdu 1075 (map)
http://acm.hdu.edu.cn/showproblem.php?pid=1075 What Are You Talking About Time Limit: 10000/5000 MS ...
- hdu 1247 map的使用
http://acm.hdu.edu.cn/showproblem.php?pid=1247 Hat’s Words Time Limit: 2000/1000 MS (Java/Others) ...
- hdu 4941 map的使用
http://acm.hdu.edu.cn/showproblem.php?pid=4941 给定N,M和K,表示在一个N*M的棋盘上有K个棋子,给出K个棋子的位置和值,然后是Q次操作,对应的是: 1 ...
- hdu 2112 HDU Today(map与dijkstra的结合使用)
HDU Today Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- HDU 5167(map + 暴力)
题意:给出一个数n,问n能否是斐波那契数列中数的乘积 先刷选 斐波那契数列,然后就枚举 #include <cstdio> #include <cstring> #includ ...
随机推荐
- redis+PHP实现的一个优先级去重队列
主要思路是用一个set做前端去重缓冲, 若干个list做后端的多优先级消息队列, 用一个进程来进行分发, 即从set中分发消息到队列. set缓冲的设计为当天有效, 所以有个零点问题,有可能在零点前s ...
- java 常量池
在jvm规范中,每个类型都有自己的常量池.常量池是某类型所用常量的一个有序集合,包括直接常量(基本类型,String)和对其他类型.字段.方法的符号引用.之所以是符号引用而不是像c语言那样,编译时直接 ...
- MySQL源码之mysqld启动
启动mysqld,并进入listen阶段 函数调用栈: mysqld_main(): my_init();初始化变量,锁,错误串 my_thread_global_init ...
- 微软开放技术开发了适用于 Windows Azure 移动服务的开源 Android SDK
发布于 2014-02-10 作者 陈 忠岳 为进一步实现连接微软与非微软技术的目标,微软开放技术有限公司开发了适用于 Windows Azure 移动服务的 Android SDK,由Scot ...
- SQL中and与or优先级比较
刚刚在项目中遇到这样一个问题,SQL语句如下: select * from LOAN_BACK_LIBRARY where LIBRARY_ID=1 or LIB_ID=1 and STATUS=3 ...
- [C# 网络编程系列]专题三:自定义Web服务器
转自:http://www.cnblogs.com/zhili/archive/2012/08/23/2652460.html 前言: 经过前面的专题中对网络层协议和HTTP协议的简单介绍相信大家对网 ...
- VS发布,TFS邮件设置截图
vs2012发布截图: TFS邮件设置截图:
- ASCII,Unicode和UTF-8字符编码
ASCII码 我们知道,在计算机内部,所有的信息最终都表示为一个二进制的字符串.每一个二进制位(bit)有0和1两种状态,因此八个二进制位就可以组合出256种状态,这被称为一个字节(byte).也就是 ...
- 解析XML文件示例
项目中要解析Xml文件,于是在工程里找了下前人写例子. 1,SAX(基于事件,效率高,使用声明加载什么). public class MVCConfig { private static MVCCon ...
- hdoj 1200 To and Fro
To and Fro Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total ...