Description

You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them.

Input

Input consists of up to 100,000 dictionary entries, followed by a blank line, followed by a message of up to 100,000 words. Each dictionary entry is a line containing an English word, followed by a space and a foreign language word. No foreign word appears more than once in the dictionary. The message is a sequence of words in the foreign language, one word on each line. Each word in the input is a sequence of at most 10 lowercase letters.

Output

Output is the message translated to English, one word per line. Foreign words not in the dictionary should be translated as "eh".

Sample Input

dog ogday
cat atcay
pig igpay
froot ootfray
loops oopslay atcay
ittenkay
oopslay

Sample Output

cat
eh
loops

分析:map学习笔记

#include<iostream>
#include<string.h>
#include<stdio.h>
#include<ctype.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include<vector>
#include<map>
#include<deque>
#include<list>
using namespace std;
char s[200];
char s1[200],s2[200];
int main()
{
map<string,string>m;
while(gets(s))
{
if(strlen(s)==0)
break;
sscanf(s,"%s%s",s1,s2);
m[s2]=s1;//映射
}
while(gets(s))
{
if(m[s].length()==0)
puts("eh");
else
cout<<m[s]<<endl;
}
return 0;
}

POJ2503——Babelfish的更多相关文章

  1. POJ2503——Babelfish(map映射+string字符串)

    Babelfish DescriptionYou have just moved from Waterloo to a big city. The people here speak an incom ...

  2. POJ2503 Babelfish map或者hash_map

    POJ2503 这是一道水题,用Map轻松AC. 不过,可以拿来测一下字符串散列, 毕竟,很多情况下map无法解决的映射问题需要用到字符串散列. 自己生成一个质数, 随便搞一下. #include&l ...

  3. POJ2503 Babelfish

    题目链接. 分析: 应当用字典树,但stl的map做很简单. #include <iostream> #include <cstdio> #include <cstdli ...

  4. POJ2503(Babelfish)--简单字典树

    思路:就是用一个字典树翻译单词的问题,我们用题目中给出的看不懂的那些单词建树,这样到每个单词的叶子结点中存放原来对应的单词就好. 这样查询到某个单词时输出叶子结点存的就行,查不到就"en&q ...

  5. poj_2503(map映射)

    题目链接poj2503 Babelfish Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 38820   Accepted: ...

  6. POJ2503:Babelfish

    浅谈\(Trie\):https://www.cnblogs.com/AKMer/p/10444829.html 题目传送门:http://poj.org/problem?id=2503 \(Trie ...

  7. Babelfish(二分查找,字符串的处理略有难度,用sscanf输入)

    Babelfish Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 28581   Accepted: 12326 题目链接: ...

  8. poj 2503:Babelfish(字典树,经典题,字典翻译)

    Babelfish Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 30816   Accepted: 13283 Descr ...

  9. POJ 2503 Babelfish

    Babelfish Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 28766 Accepted: 12407 Descripti ...

随机推荐

  1. 虚拟机安装centos 6 报错Erro processing drive

    错误提示: Error processing drive: pci-0000:00:10-scsi-0:0:0:0 20480MB VMware,VMware Virtual S This devic ...

  2. 【Sass初级】开始使用Sass和Compass

    转自:http://www.w3cplus.com/preprocessor/beginner/getting-started-with-sass-and-compass.html 如果你的朋友.同事 ...

  3. Java 循环语句之多重循环

    循环体中包含循环语句的结构称为多重循环.三种循环语句可以自身嵌套,也可以相互嵌套,最常见的就是二重循环.在二重循环中,外层循环每执行一次,内层循环要执行一圈. 如下所示: 例如:使用 * 打印长方形: ...

  4. Creole

    Home           Bisher besucht:    AnzeigenAnhängeInfo           The Creole 1.0 project has been succ ...

  5. cocos2dx+lua中cc.EventListenerMouse:create()的bug

    今天在调试项目的时候用到了鼠标事件的监听 在创建事件监听器的时候出了问题 cc.EventListenerMouse:create() 这句返回值为nil 原来这是cocos2dx引擎的一个bug,t ...

  6. ylb:表的结构的修改和基本约束

    ylbtech-SQL Server:SQL Server-表的结构的修改和基本约束 SQL Server 表的结构的修改和基本约束. 1,表的结构的修改和基本约束返回顶部 use master go ...

  7. YII Framework学习教程-YII的国际化

    一个web应用,发布到互联网,就是面向全球用户.用户在世界的各个角落都可以访问到你的web应用,当然要看你的网站和不和谐,不和谐的web应用在和谐社会是不让你访问的. YII提供了国际化的支持,可以让 ...

  8. hdu 1166 敌兵布阵(线段树单点更新,区间查询)

    题意:区间和 思路:线段树 #include<iostream> #include<stdio.h> using namespace std; #define MAXN 500 ...

  9. STL中用erase()方法遍历删除元素 .xml

    pre{ line-height:1; color:#f0caa6; background-color:#2d161d; font-size:16px;}.sysFunc{color:#e54ae9; ...

  10. C语言实现strcmp

    注意转化为unsigned char: strcmp.h #ifndef STRCMP_H #define STRCMP_H /************************************ ...