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. 【bzoj2091】[Poi2010]The Minima Game dp

    题目描述 给出N个正整数,AB两个人轮流取数,A先取.每次可以取任意多个数,直到N个数都被取走.每次获得的得分为取的数中的最小值,A和B的策略都是尽可能使得自己的得分减去对手的得分更大.在这样的情况下 ...

  2. 用Matlab对数据进行线性拟合算法

    http://www.cnblogs.com/softlin/p/5965939.html 挖坑

  3. BZOJ1061:[NOI2008]志愿者招募——题解

    https://www.lydsy.com/JudgeOnline/problem.php?id=1061 https://www.luogu.org/problemnew/show/P3980 申奥 ...

  4. UVA.548 Tree(二叉树 DFS)

    UVA.548 Tree(二叉树 DFS) 题意分析 给出一棵树的中序遍历和后序遍历,从所有叶子节点中找到一个使得其到根节点的权值最小.若有多个,输出叶子节点本身权值小的那个节点. 先递归建树,然后D ...

  5. webpack开发模式和生产模式设置及不同环境脚本执行

    1. webpack设置开发模式和生产模式 (1). DefinePlugin插件设置 new webpack.DefinePlugin({ 'process.env': { NODE_ENV: '& ...

  6. httpClient需要的jar包

  7. URAL - 1627:Join (生成树计数)

    Join 题目链接:https://vjudge.net/problem/URAL-1627 Description: Businessman Petya recently bought a new ...

  8. STM32之窗口看门狗

    1.有个7位递减计数器(WWDG->CR),就这个计数器和窗口计数器(WWDG->CFR)决定什么时候喂狗.狗喂早了,复位——“早”体现在 计数器值(tr)>窗口值(wr),也就是计 ...

  9. 第三方库升级Nginx

    通过PPA方式,来升级Nginx 1. 添加PPA sudo add-apt-repository ppa:nginx/stable sudo apt-get updatesudo apt-get u ...

  10. jq 由name获取那个radio选中了的

    $("input[name='approve']:checked").val() //获取radio选中的值;var radio_checked_val = $("#fo ...