一、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".

二、题解

        只要用Map把字典存起来,注意键值对的顺序,这里应该后面的字符串为键,前面的为值。然后再依次查找就可以了。

三、java代码

 import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap; public class Main {
public static void main(String[] args) throws IOException {
BufferedReader bfd=new BufferedReader(new InputStreamReader(System.in));
HashMap<String,String> hm=new HashMap<String,String>();
String s;
String [] seq=new String[2];
while(!(s=bfd.readLine()).equals("")){
seq=s.split(" ");
hm.put(seq[1], seq[0]);
}
while(!(s=bfd.readLine()).equals("")){
if(hm.containsKey(s))
System.out.println(hm.get(s));
else
System.out.println("eh");
}
}
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

Poj 2503 Babelfish(Map操作)的更多相关文章

  1. poj 2503 Babelfish(Map、Hash、字典树)

    题目链接:http://poj.org/bbs?problem_id=2503 思路分析: 题目数据数据量为10^5, 为查找问题,使用Hash或Map等查找树可以解决,也可以使用字典树查找. 代码( ...

  2. poj 2503 Babelfish (查找 map)

    题目:http://poj.org/problem?id=2503 不知道为什么 poj  的 数据好像不是100000,跟周赛的不一样 2000MS的代码: #include <iostrea ...

  3. POJ 2503 Babelfish(map,字典树,快排+二分,hash)

    题意:先构造一个词典,然后输入外文单词,输出相应的英语单词. 这道题有4种方法可以做: 1.map 2.字典树 3.快排+二分 4.hash表 参考博客:[解题报告]POJ_2503 字典树,MAP ...

  4. 题解报告:poj 2503 Babelfish(map)

    Description You have just moved from Waterloo to a big city. The people here speak an incomprehensib ...

  5. poj 2503 Babelfish(字典树或map或哈希或排序二分)

    输入若干组对应关系,然后输入应该单词,输出对应的单词,如果没有对应的输出eh 此题的做法非常多,很多人用了字典树,还有有用hash的,也有用了排序加二分的(感觉这种方法时间效率最差了),这里我参考了M ...

  6. poj 2503 Babelfish(字典树或着STL)

    Babelfish Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 35828   Accepted: 15320 Descr ...

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

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

  8. POJ 2503 Babelfish

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

  9. POJ 2503 Babelfish (STL)

    题目链接 Description You have just moved from Waterloo to a big city. The people here speak an incompreh ...

随机推荐

  1. 默写一个socket客户端和socket服务端的基本通信,即:收发消息

    Server: import socket sk = socket.socket() sk.bind(('192.168.0.95',8898)) #把地址绑定到套接字 sk.listen() #监听 ...

  2. JDK动态代理连接池

    JDK动态代理   1 什么是JDK动态代理 刚刚写ItcastConnection时爽么?因为Connection中的方法太多了,每个都要写,所以很累吧.累点到是没什么,可以完成功能就是好的.但是不 ...

  3. Unity 武器拖尾效果

    Pocket RPG Weapon Trails 武器拖尾效果 Asset Store地址:https://www.assetstore.unity3d.com/en/#!/content/2458 ...

  4. go语言之并发编程 channel

    前面介绍了goroutine的用法,如果有多个goroutine的话相互之间是如何传递数据和通信的呢.在C语言或者JAVA中,传输的方法包括共享内存,管道,信号.而在Go语言中,有了更方便的方法,就是 ...

  5. linux c编程:Posix消息队列

    Posix消息队列可以认为是一个消息链表. 有足够写权限的线程可以往队列中放置消息, 有足够读权限的线程可以从队列中取走消息 在某个进程往一个队列写入消息前, 并不需要另外某个进程在该队列上等待消息的 ...

  6. HR_ROS 节点信息

    https://stackoverflow.com/questions/24638063/install-node-serialport-module-on-arm-linux https://blo ...

  7. maven导入项目时,缺少部分source folder

    今天导入公司的maven项目时,少了一些source folder,运行启动正常,但是页面打不开,找不到对应的目录文件,使用maven更新项目,重启编辑器也无效. 问题描述如图所示,缺少了图中的2个目 ...

  8. Android系统OTA升级包制作【转】

    本文转载自:http://blog.csdn.net/dingfengnupt88/article/details/52882788 Android系统升级分为整包升级和差分包升级,整包升级就是将系统 ...

  9. QT 按键处理 快捷键处理 shift + ctrl

    原味地址:http://www.cnblogs.com/codingmylife/archive/2010/08/30/1812739.html CTRL+Enter发送信息的实现 在现在的即时聊天程 ...

  10. NULL 与空字符串

    空字符串 '' 不占内存空间; NULL占一个字节的空间; 空字符串 的判断用 == <> NULL值用 is null ifnull();