一、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. 九度OJ 1323:World Cup Betting(世界杯) (基础题)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:492 解决:219 题目描述: With the 2010 FIFA World Cup running, football fans th ...

  2. 【python】-- 进程与线程

    进程与线程 一.概念 1.简述: 计算机,所有的指令的操作都是有CPU来负责的,cpu是来负责运算的.OS(操作系统) 调度cpu的最小单位就是线程.程序启动后,从内存中分一块空间,把数据临时存在内存 ...

  3. 洛谷 P2051 [AHOI2009]中国象棋

    题目描述 这次小可可想解决的难题和中国象棋有关,在一个N行M列的棋盘上,让你放若干个炮(可以是0个),使得没有一个炮可以攻击到另一个炮,请问有多少种放置方法.大家肯定很清楚,在中国象棋中炮的行走方式是 ...

  4. [IOI2018]组合动作

    IOI2018 组合动作 UOJ 首先显然可以两次试出首字母 考虑增量构造 假设首字母为A,且已经试出前i个字母得到的串s 我们考虑press这样一个串s+BB+s+BX+s+BY+s+XA 首先这个 ...

  5. LookAndFeelInfo

    在读zap源码的时候碰到:UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());以下来自百度知道UIManager.s ...

  6. Bytecode Visualizer 一个好用的class字节码查看工具

    http://www.drgarbage.com/howto/install/   eclipse插件,效果如下:

  7. 我的Android进阶之旅------>如何将Activity变为半透明的对话框?

    我的Android进阶之旅------>如何将Activity变为半透明的对话框?可以从两个方面来考虑:对话框和半透明. 在定义Activity时指定Theme.Dialog主题就可以将Acti ...

  8. 剑指offer之 从尾到头打印链表

    package Problem5; import java.util.Stack; //首先定义链表结构class LinkNode{ LinkNode next; int node_value;} ...

  9. 算法(Algorithms)第4版 练习 2.2.11(1)

    实现关键代码: private static void sort(Comparable[] input, int lo, int hi) { if((lo+CUTOFF-1) >= hi) { ...

  10. DL二(稀疏自编码器 Sparse Autoencoder)

    稀疏自编码器 Sparse Autoencoder 一神经网络(Neural Networks) 1.1 基本术语 神经网络(neural networks) 激活函数(activation func ...