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

Hint

Huge input and output,scanf and printf are recommended.
#include<map>
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;
int main()
{
map<string,string> m;
string s;
while(getline(cin,s)){
if(s.empty()) break;
int p,sz=s.size();
p=s.find(' ');
string a=s.substr(,p);
string b=s.substr(p+,sz-p-);
m[b]=a;
}
string t;
while(cin>>t){
if(!m[t].empty())
cout<<m[t]<<endl;
else cout<<"eh"<<endl;
}
}

PKU2503_map应用的更多相关文章

随机推荐

  1. shell 中的$0 $1 $* $@ $# $$ $? $() $(())

    $0: 脚本本身文件名称 : 命令行第一个参数,$2为第二个,以此类推 $*: 所有参数列表 $@: 所有参数列表 $#: 参数个数 $$: 脚本运行时的PID $?: 脚本退出码 ∗与@的区别 当命 ...

  2. Linux shell一行流编程实践

    Linux下很多命令用起来真相当方便,尤其是进行批处理操作时.(话说感觉这种程序也不复杂,windows咋一直不搞一个好用的shell呢) 这里列出一些实际shell操作的应用场景,具体命令的用法与解 ...

  3. iOS - 沙盒机制(SandBox)和获取沙盒路径

    iOSAPP可以在自己的沙盒里读写文件,但是,不可以访问其他APP的沙盒.每一个APP都是一个信息孤岛,相互是不可以进行通信的,唯独可以通过URLScheme.沙盒里面的文件可以是照片.声音文件.文本 ...

  4. android 常见内存泄漏原因及解决办法

    android常见内存泄漏主要有以下几类: 一.Handler 引起的内存泄漏. 在Android开发中,我们经常会使用Handler来控制主线程UI程序的界面变化,使用非常简单方便,但是稍不注意,很 ...

  5. 关于htc m9w更新后手机无限重启的解决办法

    更新htc sense7.0后,手机无限重启.网上搜了一下,是和谷歌框架冲突的原因,但是机子本身没有root,删除不了gms.只能死马当活马医,把能看到google应用都给删了,就解决了. 步骤: 长 ...

  6. Postfix邮件

    一() 邮件相关协议 SMTP(Simple Mail Transfer Protocol)即简单邮件传输协议, 工作在TCP的25端口.它是一组用于由源地址到目的地址传送邮件的规则,由它来控制信件的 ...

  7. FZU2110 Star【计算几何】

    Overpower often go to the playground with classmates. They play and chat on the playground. One day, ...

  8. sql两列相除,保留n位小数

    ), ) from tablename 以上代码意思两列相处,然后保留4位小数.

  9. 洛谷P2801 教主的魔法 分块

    正解:分块 解题报告: 哇之前的坑还没填完就又写新博客? 不管不管,之前欠的两三篇题解大概圣诞节之前会再仔细想想然后重新写下题解趴,确实还挺难的感觉没有很好的理解呢QAQ还是太囫囵吞枣不求甚解了,这样 ...

  10. webstorm添加调试nodejs

    打开run菜单选择Edit Configurations 展开defaults菜单,选择nodejs 点击+按钮,选择Node.js,出现下面弹出框. 点击ok保存