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

其实真的没有什么好说的,本来我在想时间上会不会TM掉,要不要想个公式来构造哈希。。后来发现完全没必要,因为计算哈希的时间还是很可观的。另外一个就是在想要不要用C来写,后来还是发现。。。直接map就可以搞定了。。。被坑。。。

 #include <iostream>
#include <stdio.h>
#include <string>
#include <map> using namespace std; void split(string& aString, string& key, string& word) {
int i = aString.find(' '); string tek(aString, , i);
string tew(aString, i + );
key = tek;
word = tew;
}
int main(int argc, char const *argv[])
{
string aString, word, key;
map<string, string> dict;
while (getline(cin, aString)) {
if (aString.size() == )
break; split(aString, key, word);
dict[word] = key;
} while (cin >> aString) {
if (dict[aString] == "")
printf("eh\n");
else
cout << dict[aString] << endl;
}
return ;
}

sicily 数据结构 1014. Translation的更多相关文章

  1. 数据结构与算法课程作业--1014. Translation

    这道题思想很简单,就是用map将foreign的作为键值,english的值作为对应的映射值,然后通过直接用foreign作为map对象的下标直接查找. 本题比较烦人的一点就是输入数据,我使用了get ...

  2. 1014: [JSOI2008]火星人prefix

    1014: [JSOI2008]火星人prefix Time Limit: 10 Sec Memory Limit: 162 MB Description 火星人最近研究了一种操作:求一个字串两个后缀 ...

  3. BZOJ 1014: [JSOI2008]火星人prefix

    Sol Splay+Hash+二分答案. 用Splay维护Hash,二分答案判断. 复杂度 \(O(nlog^2n)\) PS:这题调了两个晚上因为没开long long.许久不写数据结构题感觉写完整 ...

  4. Python基础二. 数据结构、控制流、运算符、真值测试

    一.概述 数据结构上广义上有两种,单一类型和集合类型 单一类型,表示一种对象 集合类型,表示包含多种对象 Python 中的内建的数据类型有str.list.tuple.dict.set.number ...

  5. Network Address Translation(转载)

    Network Address Translation  来源:http://alexanderlaw.blog.hexun.com/9791596_d.html       地址转换用来改变源/目的 ...

  6. hiho #1014 : Trie树

    #1014 : Trie树 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi和小Ho是一对好朋友,出生在信息化社会的他们对编程产生了莫大的兴趣,他们约定好互相帮助, ...

  7. Android版数据结构与算法(三):基于链表的实现LinkedList源码彻底分析

    版权声明:本文出自汪磊的博客,未经作者允许禁止转载. LinkedList 是一个双向链表.它可以被当作堆栈.队列或双端队列进行操作.LinkedList相对于ArrayList来说,添加,删除元素效 ...

  8. 你真的懂redis的数据结构了吗?redis内部数据结构和外部数据结构揭秘

    Redis有哪些数据结构? 字符串String.字典Hash.列表List.集合Set.有序集合SortedSet. 很多人面试时都遇到过这种场景吧? 其实除了上面的几种常见数据结构,还需要加上数据结 ...

  9. 【原创】分布式之redis的三大衍生数据结构

    引言 说起redis的数据结构,大家可能对五大基础数据类型比较熟悉:String,Hash,List,Set,Sorted Set.那么除此之外,还有三大衍生数据结构,大家平时是很少接触的,即:bit ...

随机推荐

  1. 【bzoj4540】[Hnoi2016]序列 单调栈+离线+扫描线+树状数组区间修改区间查询

    题目描述 给出一个序列,多次询问一个区间的所有子区间最小值之和. 输入 输入文件的第一行包含两个整数n和q,分别代表序列长度和询问数.接下来一行,包含n个整数,以空格隔开,第i个整数为ai,即序列第i ...

  2. Go语言【第十一篇】:Go数据结构之:结构体

    Go语言结构体 Go语言中数组可以存储同一类型的数据,但在结构体中我们可以为不同项定义不同的数据类型,结构体是由一系列具有相同类型或不同类型数据构成的集合.结构体表示一项记录,比如:保存图书馆的书籍记 ...

  3. 如何正确实现Page接口分页,用PageImpl 自定义分页

    /** * Constructor of {@code PageImpl}. * * @param content the content of this page, must not be {@li ...

  4. 【题解】51nod 1203JZPLCM问题

    这题好强强啊,貌似是集训队原题?集训队原题当中值域是1e9的范围,这样各种乱搞是妥妥的不能过了,只能写正解的离线+树状数组维护前缀积. 最开始我写了几种乱搞做法,包括莫队和线段树做法.其中表现比较优秀 ...

  5. [HDU4532]湫秋系列故事——安排座位

    题面在这里 description 有\(n\)种颜色的小球,每种颜色的小球有\(a_i\)个: 要把它们摆成一排,求相邻小球颜色不相同的摆放方案数. 任意两个合理的安排方法,只要有一个位置的同学不同 ...

  6. [洛谷P3332][ZJOI2013]K大数查询

    题目大意:有$n$个位置,$m$个操作.操作有两种: $1\;l\;r\;x:$在区间$[l,r]$每个位置加上一个数$x$ $2\;l\;r\;k:$询问$[l,r]$中第$k$大的数是多少. 题解 ...

  7. Android <Android应用开发实战> 资源类型<一>

    1.字符串资源>>1.普通字符串>>2.字符串数组 <resources> <string-array name="planets_array&qu ...

  8. [Leetcode] valid parentheses 有效括号对

    Given a string containing just the characters'(',')','{','}','['and']', determine if the input strin ...

  9. jquery实现奇偶行赋值不同css值

    <html> <head> <title>jquery奇偶行css效果</title> <script src="../../jquer ...

  10. oracle数据库数据导入导出步骤(入门)

    oracle数据库数据导入导出步骤(入门) 说明: 1.数据库数据导入导出方法有多种,可以通过exp/imp命令导入导出,也可以用第三方工具导出,如:PLSQL 2.如果熟悉命令,建议用exp/imp ...