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 ...
随机推荐
- go网络编程示例,客户端,服务器端
http://blog.csdn.net/wangningyu/article/details/22859245 http://blog.csdn.net/wangningyu/article/det ...
- Android 获取图片资源的4种方式
1. 图片放在sdcard中 Bitmap imageBitmap = BitmapFactory.decodeFile(path) (path 是图片的路径,跟目录是/sdcard) 2. 图片在项 ...
- mysql 区间锁 对于没有索引 非唯一索引 唯一索引 各种情况
The locks are normally next-key locks that also block inserts into the "gap" immediately b ...
- 4.android.mk编写规范
Android.mk是Android提供的一种makefile文件,用来指定诸如编译生成so库名.引用的头文件目录.需要编译的.c/.cpp文件和.a静态库文件等.要掌握jni,就必须熟练掌握Andr ...
- 《IT运维之道》
本书共分为5篇,机遇篇.做事篇.处事篇.技能篇和高级篇,从不同的层面阐述了IT运维人员 应掌握的方法及相关知识与技能.本书作者深入浅出.化繁为简,将信息化服务中晦涩的IT标准规范.流程体系用浅显易懂的 ...
- NOI2003 文本编辑器editor
1507: [NOI2003]Editor Time Limit: 5 Sec Memory Limit: 162 MBSubmit: 1908 Solved: 738[Submit][Statu ...
- IE浏览器Ajax缓存问题小结
IE浏览器Ajax缓存问题 在IE下使用ajax的get方法向后台请求数据时,如果请求URL与之前完全一样,则根本不想后台获取,直接返回上一次请求缓存的数据(在缓存过期之前,针对相同地址发起的多个Aj ...
- 比较详细的利用虚拟机对SD卡FAT32+EXT4+Ext4分区图解教程
如果大家嫌虚拟机复杂,我这里提供一个我没用虚拟机之前的分区方法:这个方法实际是可行的 我在没有用虚拟机之前,我是这样操作的1.首先在分区软件分好fat32+ext2+ext22.然后用recovery ...
- Devexpress GridView部分常用操作总结 z
一:Clone返回新的 DataTable Clone返回新的 DataTable,与当前的 DataTable 具有相同的架构:Copy:返回新的 DataTable,它具有与该 DataTable ...
- 向Git证明自己的身份,Git别名配置
一.向Git证明自己的身份 在安装完Git后,第一步就是向Git说明自己的身份,通过如下两个命令证明: git config --global user.name "myusername&q ...