poj 1318 Word Amalgamation
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 9968 | Accepted: 4774 |
Description
Input
Output
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的更多相关文章
- Word Amalgamation(枚举 + 排序)
Word Amalgamation Time Limit: 1 Sec Memory Limit: 64 MB Submit: 373 Solved: 247 Description In mil ...
- hdu-----(1113)Word Amalgamation(字符串排序)
Word Amalgamation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- Word Amalgamation(hdoj1113)
Word Amalgamation Problem Description In millions of newspapers across the United States there is a ...
- hdu1113 Word Amalgamation(详解--map和string的运用)
版权声明:本文为博主原创文章.未经博主同意不得转载. vasttian https://blog.csdn.net/u012860063/article/details/35338617 转载请注明出 ...
- HDOJ.1113 Word Amalgamation(map)
Word Amalgamation 点我挑战题目 点我一起学习STL-MAP 题意分析 给出字典.之后给出一系列======乱序======单词,要求你查字典,如过这个乱序单词对用有多个有序单词可以输 ...
- poj1318 Word Amalgamation 字符串排序(qsort)
Word Amalgamation Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 9794 Accepted: 4701 ...
- Uva 642 - Word Amalgamation sort qsort
Word Amalgamation In millions of newspapers across the United States there is a word game called J ...
- poj 1318
http://poj.org/problem?id=1318 这个题目还是比较水的,不过也可以提升你对字符串的熟悉度以及对一些排序函数和字符函数的使用. 大概的题意就是给你一个字典,这个字典有一些单词 ...
- Word Amalgamation
Problem Description In millions of newspapers across the United States there is a word game called J ...
随机推荐
- Ubuntu12.04LTS中安装和使用Spin
https://blog.csdn.net/jackandsnow/article/details/94434481 把第三步 安装tk(在wish中):apt-get install wish 改为 ...
- c++将字符转换成字符串
转载:https://blog.csdn.net/dididisailor/article/details/83189135 char c; string str; stringstream stre ...
- 尝试实现一个简单的C语言string类型
用过`C++/Java/python/matlab/JS`等语言后,发现都能很轻松的使用string类型,而C只能这样: char str[] = "hello world"; o ...
- Linux 下安装 FFmpeg
1. 下载源代码: git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg 2. 编译 ./configure --enable-shared --pre ...
- Python—数据类型之集合(Set)
1.集合是一个无序的,且不重复元素的集合.它里面的元素是可哈希的(不可变类型),但是集合本身是不可哈希(所以集合做不了字典的键)的. 2.基本功能包括关系测试和消除重复元素.注意:集合存在的意义就是去 ...
- vue 父组件调用子组件方法简单例子(笔记)
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- QQ企业通-----客户端消息发送模块设计---知识点
Guid.NewGuid 方法 初始化 Guid 结构的新实例. Guid 结构 表示全局唯一标识符 (GUID). Encoding..::.Unicode 属性 获取使用 Little- ...
- ubuntu 12.04 配置vsftpd 服务,添加虚拟用户,ssl加密
1.对于12.04的vsftpd 有一些bug,推荐安装版本vsftpd_2.3.5-1ubuntu2ppa1_amd64.debapt-get install python-software-pro ...
- 用于云计算的自我更新、自我修补的Linux版本已发布!
自动化是 IT 行业的增长趋势,其目的是消除重复任务中的手动干扰.Oracle 通过推出 Oracle Autonomous Linux 向自动化世界迈出了又一步,这无疑将使 IoT 和云计算行业受益 ...
- 页面的五种布局以及嵌套『Android系列八』
转自:http://blog.csdn.net/dazlly/article/details/7860125 因为学习比较晚,我用的相关版本为SDK4.1.eclipse4.2,而自己看的教材都是低版 ...