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 ...
随机推荐
- leetcode面试准备: CountPrimes
1 题目 Description: Count the number of prime numbers less than a non-negative number, n. 接口:public in ...
- python-urllib2模块
参考: http://blog.csdn.net/wklken/article/details/7364390 http://hankjin.blog.163.com/blog/static/3373 ...
- Oracle core02_数据块
数据更改 oracle core完成了oracle的核心功能,recovery,读一致性等. 深入的了解oracle的机制,就从一个最简单的更新开始.对于oracle来说,最大的一个特性就是写了两次数 ...
- Datetime中yyyy-MM-dd-hh-mm-ss的格式
namespace yyyy_MM_dd_hh_mm{ class Program { static void Main(string[] args) { wh ...
- (转载)可重入函数(reentrant function)
(转载)http://blog.163.com/xu_jin_rong/blog/static/1491966220086775017178 由于cublog系统的缘故,将前段时间写的一篇blog文章 ...
- android获取package name
下载apk resigner(此被,,) 另外一个下载url 配置好android 环境,ANDROID_HOME 和路径直接到sdk,将.apk拖到此apk resigner,将会得出package ...
- HDU 4737 A Bit Fun 2013成都 网络赛 1010
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4737 题目大意:给定一系列数,F(i,j)表示对从ai到aj连续求或运算,(i<=j)求F(i, ...
- poj 1995 Raising Modulo Numbers【快速幂】
Raising Modulo Numbers Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 5477 Accepted: ...
- jmeter控制器
1.仅一次控制器 这个控制器可以保证线程在多次循环跑得情况下只登陆一次 2.循环控制器(Loop Controller:设置循环次数 结果: 3. ForEach控制器(ForEach Contro ...
- CentOS 7下安装xampp和testlink
记录一下最近安装testlink的经历,供大伙儿参考,有问题可以留言讨论,这里就不截图了 先说下安装版本: CentOS-7.0-1406-x86_64-DVDxampp-linux-1.8.3-5- ...