你刚从滑铁卢搬到了一个大城市,这里的人们讲一种难以理解的外语方言。幸运的是,你有一本字典来帮助你理解它们。
输入格式:
输入第一行是正整数N和M,后面是N行字典条目(最多10000条),然后是M行要翻译的外语单词(最多10000个)。每一个字典条目都包含一个英语单词,后面跟着一个空格和一个外语单词。 输入中的每个单词都由最多10个小写字母组成。
输出格式:
输出翻译后的英文单词,每行一个单词。非词典中的外来词汇输出“eh”。
输入样例:
5 3
dog ogday
cat atcay
pig igpay
froot ootfray
loops oopslay
atcay
ittenkay
oopslay
输出样例:
cat
eh
loops
#include<bits/stdc++.h>
#define N 500005
#define inf 0x3f3f3f3f
using namespace std;
int main(){
map<string,string>dict;
int m,n;
cin>>n>>m;
for(int i=0;i<n;i++){
string s1,s2;
cin>>s1>>s2;
dict[s2]=s1;
}
for(int i=0;i<m;i++){
string s;
cin>>s;
if(!dict.count(s))
cout<<"eh"<<endl;
else
cout<<dict[s]<<endl;
}
return 0;
}